OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / widgets / photo_main / include / container / admin_photo_mainImagebrowseWidgetContainer.php
1 <?php
2 /**
3  * コンテナクラス
4  *
5  * PHP versions 5
6  *
7  * LICENSE: This source file is licensed under the terms of the GNU General Public License.
8  *
9  * @package    Magic3 Framework
10  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11  * @copyright  Copyright 2006-2013 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: admin_photo_mainImagebrowseWidgetContainer.php 5630 2013-02-10 11:08:39Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once($gEnvManager->getCurrentWidgetContainerPath() . '/admin_photo_mainBaseWidgetContainer.php');
17
18 class admin_photo_mainImagebrowseWidgetContainer extends admin_photo_mainBaseWidgetContainer
19 {
20         private $serialArray = array();         // 表示されているファイルのインデックス番号
21         private $photoBasePath;                         // アクセス可能な画像格納ディレクトリ
22         private $sortOrderByDateAsc;            // 日付でソート
23         private $masterMimeType;                        // マスター画像のMIMEタイプ
24         private $permitMimeType;                        // アップロードを許可する画像タイプ
25         private $userId;                                        // 現在のユーザ
26         private $langId;                                        // 現在の言語
27         private $fileListAdded;                         // 一覧にデータが追加されたかどうか
28         const DEFAULT_LIST_COUNT = 30;                  // 最大リスト表示数
29         const FILE_ICON_FILE = '/images/system/tree/file.png';                  // ファイルアイコン
30         const FOLDER_ICON_FILE = '/images/system/tree/folder.png';              // ディレクトリアイコン
31         const PARENT_ICON_FILE = '/images/system/tree/parent.png';              // 親ディレクトリアイコン
32         const CALENDAR_ICON_FILE = '/images/system/calendar.png';               // カレンダーアイコン
33         const ACTIVE_ICON_FILE = '/images/system/active.png';                   // 公開中アイコン
34         const INACTIVE_ICON_FILE = '/images/system/inactive.png';               // 非公開アイコン
35         const ICON_SIZE = 16;           // アイコンのサイズ
36         const LIST_ICON_SIZE = 64;              // リスト用アイコンのサイズ
37         const CSS_FILE = '/swfupload2.5/css/default.css';               // CSSファイルのパス
38 //      const PHOTO_DIR = '/etc/photo';         // マスター画像格納ディレクトリ
39         const PHOTO_HOME_DIR = '/etc/photo/home';               // マスター画像格納ディレクトリ(ユーザ別)
40         const DEFAULT_THUMBNAIL_SIZE = 128;             // サムネール画像サイズ
41         const DEFAULT_IMAGE_EXT = 'jpg';                        // 画像ファイルのデフォルト拡張子
42         const DEFAULT_IMAGE_TYPE = IMAGETYPE_JPEG;
43         const THUMBNAIL_DIR = '/widgets/photo/image';           // 画像格納ディレクトリ
44         const IMAGE_QUALITY = 100;                      // 生成画像の品質(0~100)
45         
46         /**
47          * コンストラクタ
48          */
49         function __construct()
50         {
51                 // 親クラスを呼び出す
52                 parent::__construct();
53                 
54                 // 画像タイプ
55                 $this->masterMimeType = image_type_to_mime_type(IMAGETYPE_JPEG);                        // マスター画像のMIMEタイプ
56                 $this->permitMimeType = array(  image_type_to_mime_type(IMAGETYPE_GIF),
57                                                                                 image_type_to_mime_type(IMAGETYPE_JPEG),
58                                                                                 image_type_to_mime_type(IMAGETYPE_PNG),
59                                                                                 image_type_to_mime_type(IMAGETYPE_BMP));                        // アップロードを許可する画像タイプ
60                                                                                 
61                 $this->langId = $this->gEnv->getCurrentLanguage();
62                 $this->userId = $this->gEnv->getCurrentUserId();
63         }
64         /**
65          * テンプレートファイルを設定
66          *
67          * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
68          * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
69          *
70          * @param RequestManager $request               HTTPリクエスト処理クラス
71          * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
72          * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
73          */
74         function _setTemplate($request, &$param)
75         {
76                 $task = $request->trimValueOf('task');
77                 switch ($task){
78                         case 'imagebrowse':
79                         default:
80                                 $filename = 'imagebrowse.tmpl.html';
81                                 break;
82                         case 'imagebrowse_detail':
83                                 $filename = 'imagebrowse_detail.tmpl.html';
84                                 break;
85                         case 'imagebrowse_direct':
86                                 $filename = '';
87                                 break;
88                 }
89                 return $filename;
90         }
91         /**
92          * テンプレートにデータ埋め込む
93          *
94          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
95          *
96          * @param RequestManager $request               HTTPリクエスト処理クラス
97          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
98          * @param                                                               なし
99          */
100         function _assign($request, &$param)
101         {
102                 $act = $request->trimValueOf('act');
103                 $task = $request->trimValueOf('task');
104                 
105                 switch ($task){
106                         case 'imagebrowse':
107                         default:
108                                 $this->createList($request);
109                                 break;
110                         case 'imagebrowse_detail':
111                                 $this->createDetail($request);
112                                 break;
113                         case 'imagebrowse_direct':
114                                 if ($act == 'getimage'){                // 画像取得
115                                         $width = $request->trimValueOf('width');
116                                         $height = $request->trimValueOf('height');
117                                         $photoId = $request->trimValueOf(M3_REQUEST_PARAM_PHOTO_ID);                    // 画像ID
118                                         photo_mainCommonDef::getImage($photoId, self::$_mainDb, $width, $height);
119                                 }
120                                 break;
121                 }
122         }
123         /**
124          * 一覧画面作成
125          *
126          * @param RequestManager $request               HTTPリクエスト処理クラス
127          * @param                                                               なし
128          */
129         function createList($request)
130         {
131                 $account = $this->gEnv->getCurrentUserAccount();
132                 
133                 // パラメータエラーチェック
134                 if (empty($account)){
135                         $this->SetMsg(self::MSG_APP_ERR, $this->_('Error parameters.'));// パラメータにエラーがあります。
136                         return;
137                 }
138                 
139                 // 移動可能なディレクトリ範囲を取得
140                 if (self::$_isLimitedUser){             // 使用限定ユーザの場合
141                         $this->photoBasePath = $this->gEnv->getIncludePath() . self::PHOTO_HOME_DIR . DIRECTORY_SEPARATOR . $account;                           // 画像格納ディレクトリ
142                         
143                         // ホームディレクトリがなければ作成
144                         if (!is_dir($this->photoBasePath)) @mkdir($this->photoBasePath, M3_SYSTEM_DIR_PERMISSION);
145                 } else {
146                         $this->photoBasePath = $this->gEnv->getIncludePath() . photo_mainCommonDef::PHOTO_DIR;                          // 画像格納ディレクトリ
147                 }
148
149                 // パスを取得
150                 $path = trim($request->valueOf('path'));                // 現在のパス
151                 if (empty($path)){
152                         $path = $this->photoBasePath;
153                 } else {
154                         if (!strStartsWith($path, '/')) $path = '/' . $path;
155                         $path = $this->photoBasePath . $path;
156                 }
157                 // パスのエラーチェック
158                 if (isDescendantPath($this->photoBasePath, $path)){
159                         if (!is_dir($path)){
160                                 $this->setUserErrorMsg($this->_('Can not access the page.'));                   // アクセスできません
161                                 return;
162                         }
163                 } else {
164                         $this->setUserErrorMsg($this->_('Can not access the page.'));                   // アクセスできません
165                         return;
166                 }
167                 
168                 // ページ番号
169                 $viewCount = self::DEFAULT_LIST_COUNT;                          // 表示項目数
170                 $pageNo = $request->trimValueOf(M3_REQUEST_PARAM_PAGE_NO);                              // ページ番号
171                 if (empty($pageNo)) $pageNo = 1;
172                 
173                 $act = $request->trimValueOf('act');
174                 if ($act == 'uploadfile'){              // ファイルアップロードのとき
175                         // ページ作成処理中断
176                         $this->gPage->abortPage();
177
178                         // ファイルのアップロード処理
179                         if (isset($_FILES["Filedata"]) && is_uploaded_file($_FILES['Filedata']['tmp_name'])){           // アップロードファイルがある場合
180                                 // ファイル名を作成
181                                 $code = $account . '-' . self::$_mainDb->getNewPhotoNo($this->userId);          // 画像コード
182                                 $ret = self::$_mainDb->isExistsPhotoCode($code);                // 画像コードの重複確認
183                                 if ($ret){              // 画像コードが重複するとき
184                                         $errMessage = '画像コードが重複しています。';
185                                         $errDetail = '画像コード=' . $code;
186                                 } else {
187                                         // ファイル名は画像ファイルのハッシュを取得
188                                         //$filename = md5($code . time());
189                                         $filename = md5_file($_FILES['Filedata']['tmp_name']);
190                                         $originalFilename = $_FILES['Filedata']['name'];                // 元のファイル名
191                                         $filePath = $path . DIRECTORY_SEPARATOR . $filename;
192                                         
193                                         // 画像のアップロード状況確認
194                                         $ret = self::$_mainDb->isExistsPhoto($filename);
195                                         if ($ret){
196                                                 $errMessage = '画像ファイルが重複しています。';
197                                                 $errDetail = '画像ID=' . $filename . ', 元のファイル名=' . $originalFilename;
198                                         }
199                                 }
200                                 
201                                 if (!$ret){             // 画像の重複がない場合
202                                         if (file_exists($filePath)) $this->writeError(__METHOD__, 'アップロード画像がすでに存在しています。新しい画像で置き換えます。', 1100, '元のファイル名=' . $originalFilename);
203
204                                         // アップされたファイルをコピー
205                                         $ret = move_uploaded_file($_FILES['Filedata']['tmp_name'], $filePath);
206                                         if ($ret){
207                                                 $isErr = false;         // エラーが発生したかどうか
208
209                                                 // 画像情報を取得
210                                                 $imageSize = @getimagesize($filePath);
211                                                 if ($imageSize){
212                                                         $imageWidth = $imageSize[0];
213                                                         $imageHeight = $imageSize[1];
214                                                         $imageType = $imageSize[2];
215                                                         $imageMimeType = $imageSize['mime'];    // ファイルタイプを取得
216
217                                                         // 受付可能なファイルタイプかどうか
218                                                         if (!in_array($imageMimeType, $this->permitMimeType)){
219                                                                 $isErr = true;  
220                                                                 $this->writeUserError(__METHOD__, 'アップロード画像のタイプが不正です。アカウント: ' . $account, 2200, '元のファイル名=' . $originalFilename);
221                                                         }
222                                                 } else {
223                                                         $isErr = true;
224                                                         $this->writeUserError(__METHOD__, 'アップロード画像が不正です。アカウント: ' . $account, 2200, '元のファイル名=' . $originalFilename);
225                                                 }
226
227                                                 if (!$isErr){
228                                                         // 各種画像作成
229                                                         $ret = $this->createImages($filename, $filePath, $originalFilename, $thumbFilename);
230                                                         if (!$ret) $isErr = true;
231                                                         
232                                                         if (!$isErr){
233                                                                 //$relativePath = strtr(str_replace($this->gEnv->getIncludePath() . photo_mainCommonDef::PHOTO_DIR, '', $path), '\\', '/');             // 画像格納ディレクトリ
234                                                                 $relativePath = strtr(substr($path, strlen($this->gEnv->getIncludePath() . photo_mainCommonDef::PHOTO_DIR)), '\\', '/');                // 画像格納ディレクトリ
235                                                                 $imageSize = $imageWidth . 'x' . $imageHeight;          // 画像の縦横サイズ
236                                                                 $filesize = filesize($filePath);;                       // ファイルサイズ(バイト数)
237                                                                 $name = removeExtension($originalFilename);             // 画像名
238                                                                 $name = strtr($name, '_', ' ');
239                                                                 $camera = '';   // カメラ
240                                                                 $location = ''; // 場所
241                                                                 $date = $this->gEnv->getInitValueOfDate();              // 撮影日
242                                                                 $summary = '';          // 画像概要
243                                                                 $description = '';                      // その他情報
244                                                                 $license = '';          // ライセンス
245                                                                 $keyword = '';          // 検索情報
246                                                                 $visible = true;        // 表示
247                                                                 $ret = self::$_mainDb->updatePhotoInfo(self::$_isLimitedUser, 0/*新規追加*/, $this->langId, $filename, $relativePath, $code, $imageMimeType,
248                                                                                                 $imageSize, $originalFilename, $filesize, $name, $camera, $location, $date, $summary, $description, $license, $this->userId, 
249                                                                                                 $keyword, $visible, 0/*ソート順*/, array()/*画像カテゴリー*/, $thumbFilename, $newSerial);
250                                                                 if (!$ret){
251                                                                         $isErr = true;
252                                                                         $this->writeError(__METHOD__, 'アップロード画像のデータ登録に失敗しました。', 1100, '元のファイル名=' . $originalFilename);
253                                                                 }
254                                                         }
255                                                 }
256                                                 
257                                                 // エラー処理
258                                                 if ($isErr){
259                                                         header("HTTP/1.1 595 File Upload Error");               // エラーコードはブラウザ画面に表示される
260                                                         
261                                                         // アップロードファイル削除
262                                                         unlink($filePath);
263                                                 }
264                                         } else {
265                                                 header("HTTP/1.1 596 File Upload Error");               // エラーコードはブラウザ画面に表示される
266                                         }
267                                 } else {
268                                         header("HTTP/1.1 597 File Upload Error");               // エラーコードはブラウザ画面に表示される
269                                         $this->writeError(__METHOD__, $errMessage, 1100, $errDetail);
270                                 }
271                         } else {                        // アップロードファイルがないとき
272                                 header("HTTP/1.1 598 File Upload Error");                       // エラーコードはブラウザ画面に表示される
273                                 if (isset($_FILES["Filedata"])) echo $_FILES["Filedata"]["error"];
274                         }
275                         
276                         // システム強制終了
277                         $this->gPage->exitSystem();
278                 } else if ($act == 'delete'){                   // ファイル削除のとき
279                         $listedItem = explode(',', $request->trimValueOf('seriallist'));
280                         $delItems = array();    // シリアル番号
281                         $delPhotos = array();   // 写真ID
282                         $delFiles = array();    // ファイル名
283                         $delSystemFiles = array();              // 削除するシステム用画像ファイル
284                         for ($i = 0; $i < count($listedItem); $i++){
285                                 // 項目がチェックされているかを取得
286                                 $itemName = 'item' . $i . '_selected';
287                                 $itemValue = ($request->trimValueOf($itemName) == 'on') ? 1 : 0;
288                                 
289                                 if ($itemValue){                // チェック項目
290                                         // 削除可能かチェック
291                                         $filename = $request->trimValueOf('item' . $i . '_name');
292                                         $filePath = $path . DIRECTORY_SEPARATOR . $filename;
293                                         if (is_writable($filePath) && strStartsWith($filePath, $this->photoBasePath . DIRECTORY_SEPARATOR)){
294                                                 $serial = $listedItem[$i];
295                                                 if ($serial > 0){
296                                                         // 写真情報のアクセス権をチェック
297                                                         $ret = self::$_mainDb->getPhotoInfoBySerial($serial, $row);
298                                                         if ($ret){
299                                                                 if (!self::$_isLimitedUser || (self::$_isLimitedUser && $this->userId == $row['ht_owner_id'])){
300                                                                         $delItems[] = $serial;
301                                                                         $delPhotos[] = $filename;               // 写真ID
302                                                                         $delSystemFiles[] = $row['ht_thumb_filename'];
303                                                                 }
304                                                         }
305                                                 }
306                                                 $delFiles[] = $filePath;                // 削除するファイルのパス
307                                         } else {
308                                                 //$this->setMsg(self::MSG_USER_ERR, '削除できないファイルが含まれています。ファイル名=' . $this->convertToDispString($filename));
309                                                 $this->setMsg(self::MSG_USER_ERR, sprintf($this->_('Include files not allowed to delete. (filename: %s)'), $this->convertToDispString($filename)));             // 削除できないファイルが含まれています。(ファイル名: %s)
310                                                 break;
311                                         }
312                                 }
313                         }
314                         if ($this->getMsgCount() == 0 && count($delFiles) > 0){
315                                 $ret = self::$_mainDb->delPhotoInfo($delItems);
316                                 if ($ret){
317                                         // ファイル、ディレクトリ削除
318                                         for ($i = 0; $i < count($delFiles); $i++){
319                                                 $file = $delFiles[$i];
320                                                 if (is_dir($file)){
321                                                         // ファイル、ディレクトリがある場合は削除しない
322                                                         $files = getFileList($file);
323                                                         if (count($files) == 0){
324                                                                 if (!rmDirectory($file)) $ret = false;
325                                                         } else {
326                                                                 $ret = false;
327                                                         }
328                                                 } else {
329                                                         if (!@unlink($file)) $ret = false;
330                                                 }
331                                         }
332                                         // 公開画像、サムネールを削除
333                                         $ret = $this->deleteImages($delPhotos, $delSystemFiles);
334                                         /*for ($i = 0; $i < count($delPhotos); $i++){
335                                                 // サムネール削除
336                                                 $thumbnailPath = photo_mainCommonDef::getThumbnailPath($delPhotos[$i]);
337                                                 if (!@unlink($thumbnailPath)) $ret = false;
338                                                 $publicImagePath = photo_mainCommonDef::getPublicImagePath($delPhotos[$i]);
339                                                 if (!@unlink($publicImagePath)) $ret = false;
340                                         }*/
341                                 }
342                                 if ($ret){              // ファイル削除成功のとき
343                                         //$this->setGuidanceMsg('ファイルを削除しました');
344                                         $this->setGuidanceMsg($this->_('Files deleted.'));                      // ファイルを削除しました
345                                 } else {
346                                         //$this->setAppErrorMsg('ファイル削除に失敗しました');
347                                         $this->setAppErrorMsg($this->_('Failed in deleting files.'));                   // ファイル削除に失敗しました
348                                 }
349                         }
350                 } else if ($act == 'createdir'){                        // ディレクトリ作成のとき
351                         $dirName = $request->trimValueOf('directory_name');
352                         $this->checkSingleByte($dirName, $this->_('Directory Name'));           // ディレクトリ名
353                         
354                         if ($this->getMsgCount() == 0){
355                                 $dirPath = $path . DIRECTORY_SEPARATOR . $dirName;
356                                 $ret = @mkdir($dirPath, M3_SYSTEM_DIR_PERMISSION);
357                                 if ($ret){              // ファイル削除成功のとき
358                                         $this->setGuidanceMsg($this->_('Directory created.'));                  // ディレクトリを作成しました
359                                         $dirName = '';
360                                 } else {
361                                         $this->setAppErrorMsg($this->_('Failed in creating directory.'));                       // ディレクトリ作成に失敗しました
362                                 }
363                         }
364                 }
365                 
366                 // カレントディレクトリのパスを作成
367                 $photoParentPath = dirname($this->photoBasePath);
368                 $pathLink = '';
369                 //$relativePath = str_replace($photoParentPath, '', $path);
370                 $relativePath = substr($path, strlen($photoParentPath));
371                 $relativePath = trim($relativePath, DIRECTORY_SEPARATOR);
372                 if (!empty($relativePath)){
373                         //$absPath = $this->gEnv->getSystemRootPath();
374                         $absPath = $photoParentPath;
375                         $pathArray = explode(DIRECTORY_SEPARATOR, $relativePath);
376                         for ($i = 0; $i < count($pathArray); $i++){
377                                 if ($i == count($pathArray) -1){
378                                         $pathLink .= '&nbsp;' . DIRECTORY_SEPARATOR . '&nbsp;' . $this->convertToDispString($pathArray[$i]);
379                                 } else {
380                                         $absPath .= DIRECTORY_SEPARATOR . $pathArray[$i];
381                                         $relativeFilePath = substr($absPath, strlen($this->photoBasePath));
382                                         $pathLink .= '&nbsp;' . DIRECTORY_SEPARATOR . '&nbsp;';
383                                         //$pathLink .= '<a href="#" onclick="selDir(\'' . $this->adaptWindowsPath($this->convertToDispString($absPath)) . '\');return false;">' . $this->convertToDispString($pathArray[$i]) . '</a>';
384                                         //$pathLink .= '<a href="#" onclick="selDir(\'' . $this->adaptWindowsPath($this->convertToDispString($relativeFilePath)) . '\');return false;">' . $this->convertToDispString($pathArray[$i]) . '</a>';
385                                         $pageUrl = $this->_baseUrl . '&task=imagebrowse&path=' . $relativeFilePath;
386                                         $pathLink .= '<a href="' . $this->convertUrlToHtmlEntity($this->getUrl($pageUrl)) . '">' . $this->convertToDispString($pathArray[$i]) . '</a>';
387                                 }
388                         }
389                 }
390         
391 /*              $this->canDeleteFile = false;
392                 if ($relativePath == M3_DIR_NAME_RESOURCE || strStartsWith($relativePath, M3_DIR_NAME_RESOURCE . DIRECTORY_SEPARATOR)){
393                         $this->canDeleteFile = true;
394                 } else {
395                         // 削除ボタンを使用不可にする
396                         $this->tmpl->addVar("_widget", "del_disabled", 'disabled ');
397                 }*/
398                 
399                 // 総数を取得
400                 $fileList = $this->getFileList($path);
401                 $totalCount = count($fileList);
402
403                 // 表示するページ番号の修正
404                 $pageCount = (int)(($totalCount -1) / $viewCount) + 1;          // 総ページ数
405                 if ($pageNo < 1) $pageNo = 1;
406                 if ($pageNo > $pageCount) $pageNo = $pageCount;
407                 $this->firstNo = ($pageNo -1) * $viewCount + 1;         // 先頭番号
408                 $startNo = ($pageNo -1) * $viewCount +1;                // 先頭の行番号
409                 $endNo = $pageNo * $viewCount > $totalCount ? $totalCount : $pageNo * $viewCount;// 最後の行番号
410                 
411                 // ページング用リンク作成
412                 $pageLink = '';
413                 if ($pageCount > 1){    // ページが2ページ以上のときリンクを作成
414                         for ($i = 1; $i <= $pageCount; $i++){
415                                 if ($i == $pageNo){
416                                         $link = '&nbsp;' . $i;
417                                 } else {
418                                         //$link = '&nbsp;<a href="#" onclick="selpage(\'' . $i . '\');return false;">' . $i . '</a>';
419                                         $relativePath = substr($path, strlen($this->photoBasePath));
420                                         $pageUrl = $this->_baseUrl . '&task=imagebrowse&path=' . $relativePath;
421                                         if ($i > 1) $pageUrl .= '&page=' . $i;
422                                         $link = '&nbsp;<a href="' . $this->convertUrlToHtmlEntity($this->getUrl($pageUrl)) . '">' . $i . '</a>';
423                                 }
424                                 $pageLink .= $link;
425                         }
426                 }
427                 $this->tmpl->addVar("_widget", "page_link", $pageLink);
428                 $this->tmpl->addVar("_widget", "total_count", sprintf($this->_('%d Total'), $totalCount));// 全 x件
429                 $this->tmpl->addVar("_widget", "page", $pageNo);        // ページ番号
430                 $this->tmpl->addVar("search_range", "start_no", $startNo);
431                 $this->tmpl->addVar("search_range", "end_no", $endNo);
432                 if ($totalCount > 0) $this->tmpl->setAttribute('search_range', 'visibility', 'visible');// 検出範囲を表示
433                 
434                 // ファイル一覧を作成
435                 $this->createFileList($path, $fileList, $startNo, $endNo);
436                 if (!$this->fileListAdded) $this->tmpl->setAttribute('file_list', 'visibility', 'hidden');                              // 一覧にデータが追加されたかどうか
437                 
438                 $this->tmpl->addVar('_widget', 'path', substr($path, strlen($this->photoBasePath)));// 現在のディレクトリ
439                 $this->tmpl->addVar('_widget', 'path_link', $pathLink);// 現在のディレクトリ
440                 $this->tmpl->addVar("_widget", "serial_list", implode($this->serialArray, ','));// 表示項目のシリアル番号を設定
441                 $this->tmpl->addVar('_widget', 'directory_name', $this->convertToDispString($dirName));// ディレクトリ作成用
442                 
443                 // アップロード実行用URL
444                 $uploadUrl = $this->gEnv->getDefaultAdminUrl() . '?' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_CONFIG_WIDGET; // ウィジェット設定画面
445                 $uploadUrl .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $this->gEnv->getCurrentWidgetId();       // ウィジェットID
446                 $uploadUrl .= '&' . M3_REQUEST_PARAM_OPERATION_TASK . '=' . 'imagebrowse';
447                 $uploadUrl .= '&' . M3_REQUEST_PARAM_OPERATION_ACT . '=' . 'uploadfile';
448                 $uploadUrl .= '&' . M3_REQUEST_PARAM_ADMIN_KEY . '=' . $this->gEnv->getAdminKey();      // 管理者キー
449                 //$uploadUrl .= '&path=' . $this->adaptWindowsPath($path);
450                 $uploadUrl .= '&path=' . $this->adaptWindowsPath(substr($path, strlen($this->photoBasePath)));                                  // アップロードディレクトリ
451                 $this->tmpl->addVar("_widget", "upload_url", $this->getUrl($uploadUrl));
452                 
453                 // テキストをローカライズ
454                 $localeText = array();
455                 $localeText['msg_file_upload'] = $this->_('Files uploaded. Refresh file list?');                // アップロード終了しました。ファイル一覧を更新しますか?
456                 $localeText['msg_select_item_to_edit'] = $this->_('Select item to edit.');              // 編集する項目を選択してください
457                 $localeText['msg_select_item_to_del'] = $this->_('Select item to delete.');             // 削除する項目を選択してください
458                 $localeText['msg_delete_item'] = $this->_('Delete selected item?');             // 選択項目を削除しますか?
459                 $localeText['msg_directory_not_allowed'] = $this->_('Directory not allowed to edit.');          // ディレクトリは編集できません
460                 $localeText['msg_create_directory'] = $this->_('Create directory?');            // ディレクトリを作成しますか?
461                 $localeText['label_path'] = $this->_('Path:');          // パス
462                 $localeText['label_edit'] = $this->_('Edit');           // 編集
463                 $localeText['label_delete'] = $this->_('Delete');               // 削除
464                 $localeText['label_check'] = $this->_('Select');                // 選択
465                 $localeText['label_filename'] = $this->_('Filename');           // ファイル名
466                 $localeText['label_status'] = $this->_('Status');               // 状態
467                 $localeText['label_image_code'] = $this->_('Image Code');               // 画像コード
468                 $localeText['label_size'] = $this->_('Size');           // サイズ
469                 $localeText['label_view_count'] = $this->_('View Count');               // 閲覧数
470                 $localeText['label_rate'] = $this->_('Rating');         // 評価
471                 $localeText['label_date'] = $this->_('Update Date');            // 更新日時
472                 $localeText['label_upload'] = $this->_('Image Upload');         // 画像アップロード
473                 $localeText['label_filesize'] = $this->_('Max Filesize');               // 1ファイル最大サイズ
474                 $localeText['label_select_file'] = $this->_('Select Files');            // ファイルを選択
475                 $localeText['label_create_directory'] = $this->_('Create Directory');           // ディレクトリ作成
476                 $localeText['label_directory_name'] = $this->_('Directory Name');// ディレクトリ名
477                 $localeText['label_create'] = $this->_('Create');// 作成
478                 $localeText['label_cancel'] = $this->_('Cancel');// キャンセル
479                 $localeText['label_range'] = $this->_('Range:');                // 範囲:
480                 $this->setLocaleText($localeText);
481         }
482         /**
483          * 詳細画面作成
484          *
485          * @param RequestManager $request               HTTPリクエスト処理クラス
486          * @param                                                               なし
487          */
488         function createDetail($request)
489         {
490                 // ウィンドウ表示状態
491                 $openby = $request->trimValueOf(M3_REQUEST_PARAM_OPEN_BY);
492                 
493                 $categoryCount = self::$_configArray[photo_mainCommonDef::CF_IMAGE_CATEGORY_COUNT];                     // カテゴリ数
494                 if (empty($categoryCount)) $categoryCount = photo_mainCommonDef::DEFAULT_CATEGORY_COUNT;
495                 
496                 $act = $request->trimValueOf('act');
497                 $this->serialNo = intval($request->trimValueOf('serial'));              // 選択項目のシリアル番号
498                 $name = $request->trimValueOf('item_name');
499                 $sortOrder = $request->trimValueOf('item_sort_order');                  // 表示順
500                 $location = $request->trimValueOf('item_location');             // 撮影場所
501                 $camera = $request->trimValueOf('item_camera');         // カメラ
502                 $summary = $request->trimValueOf('item_summary');                       // 画像概要
503                 if (self::$_configArray[photo_mainCommonDef::CF_HTML_PHOTO_DESCRIPTION]){               // HTMLタイプの説明のとき
504                         $description = $request->valueOf('item_description');                   // 画像説明
505                 } else {
506                         $description = $request->trimValueOf('item_description');                       // 画像説明
507                 }
508                 $keyword = $request->trimValueOf('item_keyword');       // 検索キーワード
509                 $visible = ($request->trimValueOf('item_visible') == 'on') ? 1 : 0;             // チェックボックス
510                 $photoDate = $request->trimValueOf('item_date');                // 撮影日
511                 if (!empty($photoDate)) $photoDate = $this->convertToProperDate($photoDate);
512                 
513                 // カテゴリーを取得
514                 $categoryArray = array();
515                 for ($i = 0; $i < $categoryCount; $i++){
516                         $itemName = 'item_category' . $i;
517                         $itemValue = $request->trimValueOf($itemName);
518                         if (!empty($itemValue)){                // 0以外の値を取得
519                                 $categoryArray[] = $itemValue;
520                         }
521                 }
522                 
523                 $reloadData = false;            // データの再読み込み
524                 if ($act == 'update'){          // 行更新のとき
525                         // 入力チェック
526                         $this->checkInput($name, $this->_('Name'));             // 名前
527                         $this->checkNumeric($sortOrder, '表示順');
528                         
529                         // エラーなしの場合は、データを更新
530                         if ($this->getMsgCount() == 0){
531                                 $ret = self::$_mainDb->updatePhotoInfo(self::$_isLimitedUser, $this->serialNo/*更新*/, $this->langId, ''/*ファイル名*/, ''/*格納ディレクトリ*/, ''/*画像コード*/, ''/*画像MIMEタイプ*/,
532                                                                 ''/*画像縦横サイズ*/, ''/*元のファイル名*/, ''/*ファイルサイズ*/, $name, $camera, $location, $photoDate, $summary, $description, ''/*ライセンス*/, 0/*所有者*/, $keyword, $visible, $sortOrder, $categoryArray/*画像カテゴリー*/, ''/*サムネールファイル名*/, $newSerial);
533                                 if ($ret){              // データ追加成功のとき
534                                         $this->setMsg(self::MSG_GUIDANCE, $this->_('Item updated.'));           // データを更新しました
535                                         $this->serialNo = $newSerial;
536                                         $reloadData = true;             // データの再読み込み
537                                 } else {
538                                         $this->setMsg(self::MSG_APP_ERR, $this->_('Failed in updating item.'));         // データ更新に失敗しました
539                                 }
540                         }
541                 } else if ($act == 'delete'){           // 削除のとき
542                         $ret = self::$_mainDb->getPhotoInfoBySerial($this->serialNo, $row);
543                         if ($ret){
544                                 $delItems = array($this->serialNo);     // シリアル番号
545                                 $delPhotos = array($row['ht_public_id']);       // 公開画像ID
546                                 $imagePath = $this->gEnv->getIncludePath() . photo_mainCommonDef::PHOTO_DIR . $row['ht_dir'] . DIRECTORY_SEPARATOR . $row['ht_public_id'];
547                                 $delFiles = array($imagePath);  // ファイル名
548                                 $delSystemFiles = array($row['ht_thumb_filename']);             // 削除するシステム用画像ファイル
549                                 
550                                 // 写真情報削除
551                                 $ret = self::$_mainDb->delPhotoInfo($delItems);
552                                 if ($ret){
553                                         // ファイル、ディレクトリ削除
554                                         for ($i = 0; $i < count($delFiles); $i++){
555                                                 $file = $delFiles[$i];
556                                                 if (is_dir($file)){
557                                                         // ファイル、ディレクトリがある場合は削除しない
558                                                         $files = getFileList($file);
559                                                         if (count($files) == 0){
560                                                                 if (!rmDirectory($file)) $ret = false;
561                                                         } else {
562                                                                 $ret = false;
563                                                         }
564                                                 } else {
565                                                         if (!@unlink($file)) $ret = false;
566                                                 }
567                                         }
568                                         // 公開画像、サムネールを削除
569                                         $ret = $this->deleteImages($delPhotos, $delSystemFiles);
570                                         /*for ($i = 0; $i < count($delPhotos); $i++){
571                                                 $thumbnailPath = photo_mainCommonDef::getThumbnailPath($delPhotos[$i]);
572                                                 if (!@unlink($thumbnailPath)) $ret = false;
573                                                 $publicImagePath = photo_mainCommonDef::getPublicImagePath($delPhotos[$i]);
574                                                 if (!@unlink($publicImagePath)) $ret = false;
575                                         }*/
576                                 }
577                                 if ($ret){              // ファイル削除成功のとき
578                                         //$this->setGuidanceMsg('ファイルを削除しました');
579                                         $this->setGuidanceMsg($this->_('Files deleted.'));                      // ファイルを削除しました
580                                 } else {
581                                         //$this->setAppErrorMsg('ファイル削除に失敗しました');
582                                         $this->setAppErrorMsg($this->_('Failed in deleting files.'));                   // ファイル削除に失敗しました
583                                 }
584                         } else {
585                                 $this->setAppErrorMsg($this->_('Failed in deleting files.'));                   // ファイル削除に失敗しました
586                         }
587                 } else if ($act == 'recreate_image'){           // 画像再作成のとき
588                         $ret = self::$_mainDb->getPhotoInfoBySerial($this->serialNo, $row);
589                         if ($ret){
590                                 $photoId                = $row['ht_public_id'];
591                                 $originalName   = $row['ht_original_filename'];
592                                 $imagePath              = $this->gEnv->getIncludePath() . photo_mainCommonDef::PHOTO_DIR . $row['ht_dir'] . DIRECTORY_SEPARATOR . $row['ht_public_id'];
593                                 $ret = $this->createImages($photoId, $imagePath, $originalName, $thumbFilename);
594                                 if ($ret){              // ファイル削除成功のとき
595                                         $this->setGuidanceMsg($this->_('Images recreated.'));                   // 画像再作成しました
596                                 }
597                         }
598                         $reloadData = true;             // データの再読み込み
599                 } else {
600                         // 初期値を設定
601                         $reloadData = true;             // データの再読み込み
602                 }
603                 $isPhtoInfo = false;            // 画像情報があるかどうか
604                 if ($reloadData){               // データの再読み込み
605                         $ret = self::$_mainDb->getPhotoInfoBySerial($this->serialNo, $row, $categoryRows);
606                         if ($ret){
607                                 $name = $row['ht_name'];
608                                 $photoId = $row['ht_public_id'];
609                                 $photoCode = $row['ht_code'];
610                                 $originalName = $row['ht_original_filename'];
611                                 $size = $row['ht_image_size'];
612                                 $author = $row['lu_name'];
613                                 $sortOrder = $row['ht_sort_order'];             // ソート順
614                                 $location = $row['ht_location'];                // 撮影場所
615                                 $camera = $row['ht_camera'];            // カメラ
616                                 $summary = $row['ht_summary'];                  // 画像概要
617                                 $description = $row['ht_description'];                  // 画像説明
618                                 $keyword = $row['ht_keyword'];  // 検索キーワード
619                                 $visible = $row['ht_visible'];          // 公開
620                                 $photoDate = $this->convertToDispDate($row['ht_date']); // 撮影日
621                                 $photoTime = $this->convertToDispTime($row['ht_time'], 1/*時分*/);    // 撮影時間
622                                 
623                                 // 画像サイズ
624                                 list($width, $height) = explode('x', $row['ht_image_size']);
625                                 $originalWidth = $width;
626                                 $originalHeight = $height;
627                                 
628                                 // 画像フォーマット
629                                 $mimeType = $row['ht_mime_type'];
630                                 $format = '未検出';
631                                 if ($mimeType == image_type_to_mime_type(IMAGETYPE_GIF)){
632                                         $format = 'GIF';
633                                 } else if ($mimeType == image_type_to_mime_type(IMAGETYPE_JPEG)){
634                                         $format = 'JPEG';
635                                 } else if ($mimeType == image_type_to_mime_type(IMAGETYPE_PNG)){
636                                         $format = 'PNG';
637                                 } else if ($mimeType == image_type_to_mime_type(IMAGETYPE_BMP)){
638                                         $format = 'BMP';
639                                 }
640                                 
641                                 // 画像URL取得
642                                 photo_mainCommonDef::adjustImageSize($width, $height, photo_mainCommonDef::DEFAULT_PUBLIC_IMAGE_SIZE);
643                                 $originalImageUrl = $this->_baseUrl . '&task=imagebrowse_direct&act=getimage&' . M3_REQUEST_PARAM_PHOTO_ID . '=' . $photoId;            // 元の写真
644                                 $imageUrl = $originalImageUrl . '&width=' . $width . '&height=' . $height;// 画像
645                                 $imageTag = '<img src="' . $this->getUrl($imageUrl) . '" width="' . $width . '" height="' . $height . '" border="0" alt="' . $photoId . '" title="' . $photoId . '" />';
646                                 
647                                 // 記事カテゴリー取得
648                                 $categoryArray = $this->getCategory($categoryRows, $categoryCount);
649                                 
650                                 $isPhtoInfo = true;             // 画像情報があるかどうか
651                         } else {
652                                 $this->setAppErrorMsg($this->_('Can not find photo information.'));                     // 画像情報が見つかりません
653                         }
654                 }
655                 // 入力領域の表示制御
656                 if (!self::$_configArray[photo_mainCommonDef::CF_USE_PHOTO_DATE]){
657                         $this->tmpl->setAttribute('show_photo_date', 'visibility', 'hidden');                   // 画像情報(撮影日)を使用
658                         $this->tmpl->setAttribute('show_calender', 'visibility', 'hidden');                             // カレンダーを作成しない
659                 }
660                 if (!self::$_configArray[photo_mainCommonDef::CF_USE_PHOTO_LOCATION]) $this->tmpl->setAttribute('show_photo_location', 'visibility', 'hidden'); // 画像情報(撮影場所)を使用
661                 if (!self::$_configArray[photo_mainCommonDef::CF_USE_PHOTO_CAMERA]) $this->tmpl->setAttribute('show_photo_camera', 'visibility', 'hidden');             // 画像情報(カメラ)を使用
662                 if (self::$_configArray[photo_mainCommonDef::CF_USE_PHOTO_DESCRIPTION]){
663                         if (self::$_configArray[photo_mainCommonDef::CF_HTML_PHOTO_DESCRIPTION]) $this->tmpl->setAttribute('show_html_description', 'visibility', 'visible');           // HTMLエディターを表示
664                 } else {
665                         $this->tmpl->setAttribute('show_photo_description', 'visibility', 'hidden');    // 画像情報(説明)を使用
666                 }
667                 if (!self::$_configArray[photo_mainCommonDef::CF_USE_PHOTO_KEYWORD]) $this->tmpl->setAttribute('show_photo_keyword', 'visibility', 'hidden');   // 画像情報(検索キーワード)を使用
668                 if (!self::$_configArray[photo_mainCommonDef::CF_USE_PHOTO_CATEGORY]) $this->tmpl->setAttribute('show_photo_category', 'visibility', 'hidden'); // 画像情報(カテゴリー)を使用
669                 
670                 // カテゴリーメニューを作成
671                 if (self::$_configArray[photo_mainCommonDef::CF_USE_PHOTO_CATEGORY]){   // 画像情報(カテゴリー)を使用のとき
672                         $ret = self::$_mainDb->getAllCategory($this->langId, $allCategoryRows);
673                         if ($ret) $this->createCategoryMenu($allCategoryRows, $categoryArray, $categoryCount);
674                 }
675                 
676                 // サムネールのURLの作成
677                 $thumbnailUrlHtml = '';
678                 $thumbailSizeArray = trimExplode(',', self::$_configArray[photo_mainCommonDef::CF_THUMBNAIL_SIZE]);
679                 if (empty($thumbailSizeArray)) $thumbailSizeArray = array(photo_mainCommonDef::DEFAULT_THUMBNAIL_SIZE);
680                 for ($i = 0; $i < count($thumbailSizeArray); $i++){
681                         $thumbnailSize = $thumbailSizeArray[$i];
682                         $thumbnailPath = photo_mainCommonDef::getThumbnailPath($photoId, $thumbnailSize);
683                         if (file_exists($thumbnailPath)){               // サムネールが存在するとき
684                                 $thumbnailUrlHtml .= '<b><font color="green">';
685                         } else {
686                                 $thumbnailUrlHtml .= '<b><font color="red">';
687                         }
688                         $thumbnailUrlHtml .= $this->convertToDispString($this->getUrl(photo_mainCommonDef::getThumbnailUrl($photoId, $thumbnailSize)));
689                         $thumbnailUrlHtml .= '</font></b><br />';
690                 }
691                                                                 
692                 // 取得データを設定
693                 $this->tmpl->addVar("_widget", "serial", $this->serialNo);
694                 $this->tmpl->addVar("_widget", "photo_id", $this->convertToDispString($photoId));
695                 $this->tmpl->addVar("_widget", "code", $this->convertToDispString($photoCode));
696                 $this->tmpl->addVar("_widget", "name", $this->convertToDispString($name));
697                 $this->tmpl->addVar("_widget", "sort_order", $this->convertToDispString($sortOrder));
698                 $this->tmpl->addVar("_widget", "original_name", $this->convertToDispString($originalName));
699                 $this->tmpl->addVar("_widget", "image_tag", $imageTag);
700                 $this->tmpl->addVar("_widget", "image_url", $this->getUrl($originalImageUrl));
701                 $this->tmpl->addVar("_widget", "format", $this->convertToDispString($format));
702                 $this->tmpl->addVar("_widget", "size", $this->convertToDispString($size));
703                 $this->tmpl->addVar("_widget", "author", $this->convertToDispString($author));
704                 $this->tmpl->addVar("_widget", "summary", $this->convertToDispString($summary));                        // 画像概要
705                 if (self::$_configArray[photo_mainCommonDef::CF_USE_PHOTO_LOCATION]){   // 画像情報(撮影場所)を使用のとき
706                         $this->tmpl->addVar("show_photo_location", "location", $this->convertToDispString($location));  // 撮影場所
707                 }
708                 if (self::$_configArray[photo_mainCommonDef::CF_USE_PHOTO_CAMERA]){             // 画像情報(カメラ)を使用のとき
709                         $this->tmpl->addVar("show_photo_camera", "camera", $this->convertToDispString($camera));                // カメラ
710                 }
711                 if (self::$_configArray[photo_mainCommonDef::CF_USE_PHOTO_DESCRIPTION]){                // 画像情報(説明)を使用のとき
712                         $this->tmpl->addVar("show_photo_description", "description", $this->convertToDispString($description));
713                 }
714                 if (self::$_configArray[photo_mainCommonDef::CF_USE_PHOTO_KEYWORD]){    // 画像情報(検索キーワード)を使用のとき
715                         $this->tmpl->addVar("show_photo_keyword", "keyword", $this->convertToDispString($keyword));     // 検索キーワード
716                 }
717                 if (self::$_configArray[photo_mainCommonDef::CF_USE_PHOTO_DATE]){               // 画像情報(撮影日)を使用のとき
718                         $this->tmpl->addVar("show_photo_date", "date", $photoDate);     // 撮影日
719                         $this->tmpl->addVar('show_photo_date', 'calendar_img', $this->getUrl($this->gEnv->getRootUrl() . self::CALENDAR_ICON_FILE));    // カレンダーアイコン
720                 }
721                 $this->tmpl->addVar('_widget', 'public_image_url', $this->convertToDispString($this->getUrl(photo_mainCommonDef::getPublicImageUrl($photoId))));        // 公開画像URL
722                 $this->tmpl->addVar('_widget', 'thumbnail_url', $thumbnailUrlHtml);     // サムネール画像URL
723                 $checkedStr = '';
724                 if ($visible) $checkedStr = 'checked';
725                 $this->tmpl->addVar("_widget", "visible", $checkedStr);         // 公開
726                 
727                 if (!empty($this->serialNo) && $isPhtoInfo){            // 新規以外で画像情報がある場合
728                         $this->tmpl->setAttribute('update_button', 'visibility', 'visible');// 更新、削除ボタン表示
729                 }
730                 // 「戻る」ボタンの表示
731                 if ($openby == 'simple' || $openby == 'tabs') $this->tmpl->setAttribute('cancel_button', 'visibility', 'hidden');               // 詳細画面のみの表示またはタブ表示のときは戻るボタンを隠す
732         }
733         /**
734          * ファイル一覧を作成
735          *
736          * @param string $path          パス
737          * @param array $fileList       ファイル一覧
738          * @param int $startNo          開始番号
739          * @param int $endNo            終了番号
740          * @return なし
741          */
742         function createFileList($path, $fileList, $startNo, $endNo)
743         {
744                 // 親ディレクトリを追加
745                 if ($path != $this->photoBasePath){
746                         $file = '..';
747                         $relativeFilePath = substr(dirname($path), strlen($this->photoBasePath));
748                         //$fileLink = '<a href="#" onclick="selDir(\'' . $this->adaptWindowsPath($this->convertToDispString(dirname($path))) . '\');return false;">' . $this->convertToDispString($file) . '</a>';
749                         //$fileLink = '<a href="#" onclick="selDir(\'' . $this->adaptWindowsPath($this->convertToDispString($relativeFilePath)) . '\');return false;">' . $this->convertToDispString($file) . '</a>';
750                         $pageUrl = $this->_baseUrl . '&task=imagebrowse&path=' . $relativeFilePath;
751                         $fileLink = '<a href="' . $this->convertUrlToHtmlEntity($this->getUrl($pageUrl)) . '">' . $this->convertToDispString($file) . '</a>';
752                                         
753                         // アイコン作成
754                         $iconTitle = $file;
755                         $iconUrl = $this->gEnv->getRootUrl() . self::PARENT_ICON_FILE;
756                         $iconTag = '<a href="' . $this->convertUrlToHtmlEntity($this->getUrl($pageUrl)) . '">';
757                         $iconTag .= '<img src="' . $this->getUrl($iconUrl) . '" width="' . self::ICON_SIZE . '" height="' . self::ICON_SIZE . '" border="0" alt="' . $iconTitle . '" title="' . $iconTitle . '" />';
758                         $iconTag .= '</a>';
759                         
760                         $checkDisabled = 'disabled ';
761                         $row = array(
762                                 'icon'          => $iconTag,            // アイコン
763                                 'name'          => $this->convertToDispString($file),                   // ファイル名
764                                 'filename'    => $fileLink,                     // ファイル名
765                                 'size'     => $size,                    // ファイルサイズ
766                                 'check_disabled' => $checkDisabled,             // チェックボックス使用制御
767                                 'selected' => $selected                                                                                                         // 選択中かどうか
768                         );
769                         $this->tmpl->addVars('file_list', $row);
770                         $this->tmpl->parseTemplate('file_list', 'a');
771                         
772                         $this->fileListAdded = true;                            // 一覧にデータが追加されたかどうか
773                 }
774                         
775                 $index = 0;                     // インデックス番号
776                 //for ($i = 0; $i < count($fileList); $i++){
777                 for ($i = $startNo -1; $i < $endNo; $i++){
778                         $filePath = $fileList[$i];
779                         $relativeFilePath = substr($filePath, strlen($this->photoBasePath));
780
781                         //$pathParts = pathinfo($filePath);
782                         ////$file = basename($filePath);
783                         //$file = $pathParts['basename'];
784                         $file = end(explode('/', $filePath));                   // pathinfo,basenameは日本語処理できないので日本語対応
785                         $size = '';
786                         $fileLink = '';
787                         $filenameOption = '';                   // ファイル名オプション
788                         $code = '';                     // 画像コード
789                         $checkDisabled = '';            // チェックボックス使用制御
790                         $statusImg = '';                        // 状態
791                         $rating = '';                   // 評価
792                         if (is_dir($filePath)){                 // ディレクトリのとき
793                                 // アイコン作成
794                                 $iconUrl = $this->gEnv->getRootUrl() . self::FOLDER_ICON_FILE;
795                                 $iconTitle = $this->convertToDispString($file);
796                                 $pageUrl = $this->_baseUrl . '&task=imagebrowse&path=' . $relativeFilePath;
797                                 $iconTag = '<a href="' . $this->convertUrlToHtmlEntity($this->getUrl($pageUrl)) . '">';
798                                 $iconTag .= '<img src="' . $this->getUrl($iconUrl) . '" width="' . self::ICON_SIZE . '" height="' . self::ICON_SIZE . '" border="0" alt="' . $iconTitle . '" title="' . $iconTitle . '" />';
799                                 $iconTag .= '</a>';
800                         
801                                 $fileLink = '<a href="' . $this->convertUrlToHtmlEntity($this->getUrl($pageUrl)) . '">' . $this->convertToDispString($file) . '</a>';
802                                 
803                                 // ファイルまたはディレクトリがないときは削除可能
804                                 $files = getFileList($filePath);
805                                 if (count($files) > 0){
806                                         $checkDisabled = 'disabled ';           // チェックボックス使用制御
807                                 }
808                                 $serial = -1;
809                                 
810                                 $totalViewCount = '';           // 総参照数
811                         } else {                // 画像ファイルのとき
812                                 // 画像情報取得
813                                 $ret = self::$_mainDb->getPhotoInfo($file, $this->langId, $row, $categoryRows);
814                                 if ($ret){
815                                         $serial = $row['ht_serial'];
816                                         $code = $row['ht_code'];                        // 画像コード
817                                         $rating = $row['ht_rate_average'];                      // 評価
818                                         // 所属カテゴリー
819                                         $categoryStr = '';
820                                         $categoryCount = count($categoryRows);
821                                         for ($j = 0; $j < $categoryCount; $j++){
822                                                 $categoryStr .= $categoryRows[$j]['hc_name'];
823                                                 if ($j < $categoryCount -1) $categoryStr .= ', ';
824                                         }
825                                         $filenameOption = '<br />元のファイル名: ' . $this->convertToDispString($row['ht_original_filename']);         // ファイル名オプション
826                                         $filenameOption .= '<br />タイトル名: ' . $this->convertToDispString($row['ht_name']);           // タイトル名
827                                         $filenameOption .= '<br />カテゴリー: ' . $this->convertToDispString($categoryStr);              // 所属カテゴリー
828                                         
829                                         // 使用限定ユーザの場合は、所有者でなければ削除できない
830                                         if (self::$_isLimitedUser && $this->userId != $row['ht_owner_id']){
831                                                 $checkDisabled = 'disabled ';           // チェックボックス使用制御
832                                                 $serial = -1;
833                                         }
834                                 } else {
835                                         if (self::$_isLimitedUser){             // 使用限定ユーザの場合は削除不可
836                                                 $checkDisabled = 'disabled ';           // チェックボックス使用制御
837                                                 $serial = -1;
838                                         }
839                                 }
840                                 // ファイル削除用チェックボックス
841                                 //if (!$this->canDeleteFile || !is_writable($filePath)) $checkDisabled = 'disabled ';           // チェックボックス使用制御
842                                 
843                                 $thumbnailPath = photo_mainCommonDef::getThumbnailPath($file);
844                                 
845                                 // アイコン作成
846                                 $iconTitle = $this->convertToDispString($file);
847                                 if (file_exists($thumbnailPath)){       // サムネールが存在する場合
848                                         $iconUrl = photo_mainCommonDef::getThumbnailUrl($file);
849                                         $iconTag = '<a href="#" onclick="editItemBySerial(' . $serial . ');return false;">';
850                                         $iconTag .= '<img src="' . $this->getUrl($iconUrl) . '" width="' . self::LIST_ICON_SIZE . '" height="' . self::LIST_ICON_SIZE . '" border="0" alt="' . $iconTitle . '" title="' . $iconTitle . '" />';
851                                         $iconTag .= '</a>';
852                                 } else {
853                                         $iconUrl = $this->gEnv->getRootUrl() . self::FILE_ICON_FILE;
854                                         $iconTag = '<a href="#" onclick="editItemBySerial(' . $serial . ');return false;">';
855                                         $iconTag .= '<img src="' . $this->getUrl($iconUrl) . '" width="' . self::ICON_SIZE . '" height="' . self::ICON_SIZE . '" border="0" alt="' . $iconTitle . '" title="' . $iconTitle . '" />';
856                                         $iconTag .= '</a>';
857                                 }
858                                 
859                                 //$fileLink = $this->convertToDispString($file);
860                                 $fileLink = '<a href="#" onclick="editItemBySerial(' . $serial . ');return false;">' . $this->convertToDispString($file) . '</a>';
861                                 $size = filesize($filePath);
862                                 
863                                 // 総参照数
864                                 //$totalViewCount = $this->gInstance->getAnalyzeManager()->getTotalContentViewCount(photo_mainCommonDef::REF_TYPE_CONTENT, $row['ht_id']);
865                                 $totalViewCount = $row['ht_view_count'];
866                                 
867                                 // 公開状態
868                                 $isActive = false;              // 公開状態
869                                 if ($row['ht_visible']) $isActive = true;// 表示可能
870                 
871                                 if ($isActive){         // コンテンツが公開状態のとき
872                                         $iconUrl = $this->gEnv->getRootUrl() . self::ACTIVE_ICON_FILE;                  // 公開中アイコン
873                                         $iconTitle = $this->_('Published');
874                                 } else {
875                                         $iconUrl = $this->gEnv->getRootUrl() . self::INACTIVE_ICON_FILE;                // 非公開アイコン
876                                         $iconTitle = $this->_('Unpublished');
877                                 }
878                                 $statusImg = '<img src="' . $this->getUrl($iconUrl) . '" width="' . self::ICON_SIZE . '" height="' . self::ICON_SIZE . '" border="0" alt="' . $iconTitle . '" title="' . $iconTitle . '" />';
879                         }
880         
881                         // ファイル更新日時
882                         $updateDate = date('Y/m/d H:i:s', filemtime($filePath));
883                         
884                         $row = array(
885                                 'serial'        => $serial,
886                                 'index'         => $index,                      // インデックス番号(チェックボックス識別)
887                                 'icon'          => $iconTag,            // アイコン
888                                 'name'          => $this->convertToDispString($file),                   // ファイル名
889                                 'filename'      => $fileLink,                   // ファイル名
890                                 'filename_option'       => $filenameOption,                     // ファイル名オプション
891                                 'code'          => $this->convertToDispString($code),                   // 画像コード
892                                 'size'                  => $size,                       // ファイルサイズ
893                                 'date'    => $updateDate,                       // 更新日時
894                                 'view_count' => $totalViewCount,                                                                        // 総参照数
895                                 'rate' => $this->convertToDispString($rating),                                                                  // 評価
896                                 'status' => $statusImg,                                                                                         // 公開状況
897                                 'check_disabled' => $checkDisabled,             // チェックボックス使用制御
898                         );
899                         $this->tmpl->addVars('file_list', $row);
900                         $this->tmpl->parseTemplate('file_list', 'a');
901                         
902                         // インデックス番号を保存
903                         $this->serialArray[] = $serial;
904                         $index++;
905                         $this->fileListAdded = true;                            // 一覧にデータが追加されたかどうか
906                 }
907         }
908         /**
909          * ファイル一覧を作成
910          *
911          * @param string $path  ディレクトリパス
912          * @return array                ファイルパスのリスト
913          */
914         function getFileList($path)
915         {
916                 $fileList = array();
917                 
918                 // 引数エラーチェック
919                 if (!is_dir($path)) return $fileList;
920                 
921                 $dir = dir($path);
922                 while (($file = $dir->read()) !== false){
923                         $filePath = $path . DIRECTORY_SEPARATOR . $file;
924                         // カレントディレクトリかどうかチェック
925                         if ($file != '.' && $file != '..') $fileList[] = $filePath;
926                 }
927                 $dir->close();
928                 
929                 // 一覧を日付でソート
930                 $this->sortOrderByDateAsc = false;      // 日付で降順にソート
931                 usort($fileList, array($this, 'sortOrderByDate'));
932                 
933                 return $fileList;
934         }
935         /**
936          * ファイルパスを日付で昇順にソートする。ディレクトリは先頭。
937          *
938          * @param string        $path1                  比較するパス1
939          * @param string        $path2                  比較するパス2
940          * @return int                                          同じとき0、$path1が$path2より大きいとき1,$path1が$path2より小さいとき-1を返す
941          */
942         function sortOrderByDate($path1, $path2)
943         {
944                 // ディレクトリは常に先頭に表示
945                 if (is_dir($path1)){                    // ディレクトリのとき
946                         if (!is_dir($path2)) return -1; // ファイルのとき
947                 } else {
948                         if (is_dir($path2)) return 1;   // ディレクトリのとき
949                 }
950                 $fileTime1 = filemtime($path1);
951                 $fileTime2 = filemtime($path2);
952                 
953                 if ($fileTime1 == $fileTime2) return 0;
954                 if ($this->sortOrderByDateAsc){ // 日付で昇順にソート
955                         return ($fileTime1 < $fileTime2) ? -1 : 1;
956                 } else {
957                         return ($fileTime1 > $fileTime2) ? -1 : 1;
958                 }
959         }
960         /**
961          * CSSファイルをHTMLヘッダ部に設定
962          *
963          * CSSファイルをHTMLのheadタグ内に追加出力する。
964          * _assign()よりも後に実行される。
965          *
966          * @param RequestManager $request               HTTPリクエスト処理クラス
967          * @param object         $param                 任意使用パラメータ。
968          * @return string                                               CSS文字列。出力しない場合は空文字列を設定。
969          */
970         function _addCssFileToHead($request, &$param)
971         {
972                 return $this->getUrl($this->gEnv->getScriptsUrl() . self::CSS_FILE);
973         }
974         /**
975          * windowパスを使用する場合は、Javascriptに認識させる
976          *
977          * @param string         $src                   パス文字列
978          * @return string                                               作成文字列
979          */
980         function adaptWindowsPath($src)
981         {
982                 // 「\」を有効にする
983                 if (DIRECTORY_SEPARATOR == '\\'){               // windowsパスのとき
984                         return addslashes($src);
985                 } else {
986                         return $src;
987                 }
988         }
989         /**
990          * サムネールを作成
991          *
992          * @param string $path          ファイルパス
993          * @param int $type                     画像タイプ
994          * @param string $destPath      出力ファイル保存のパス
995          * @param int $destType         出力画像タイプ
996          * @param int $size                     サムネールの縦横サイズ
997          * @return bool                         true=成功、false=失敗
998          */
999         function createThumbImage($path, $type, $destPath, $destType, $size)
1000         {
1001                 // 画像作成
1002                 switch ($type){
1003                         case IMAGETYPE_GIF:
1004                                 $image = @imagecreatefromgif($path);
1005                                 break;
1006                         case IMAGETYPE_JPEG:
1007                                 $image = @imagecreatefromjpeg($path);
1008                                 break;
1009                         case IMAGETYPE_PNG:
1010                                 $image = @imagecreatefrompng($path);
1011                                 break;
1012                         default:
1013                                 return false;
1014                 }
1015
1016                 // 画像サイズ取得
1017                 $width = imagesx($image);
1018                 $height = imagesy($image);
1019
1020                 if ($width > $height){
1021                         $n_height = $height * ($size / $width);
1022                         $n_width = $size;
1023                 } else {
1024                         $n_width = $width * ($size / $height);
1025                         $n_height = $size;
1026                 }
1027                 
1028                 $x = 0;
1029                 $y = 0;
1030                 if ($n_width < $size) $x = round(($size - $n_width) / 2);
1031                 if ($n_height < $size) $y = round(($size - $n_height) / 2);
1032                 
1033                 // サムネールの背景色を取得
1034                 $bgColor = self::$_configArray[photo_mainCommonDef::CF_THUMBNAIL_BG_COLOR];     // サムネール背景色
1035                 $bgColorR = intval(substr($bgColor, 1, 2), 16);
1036                 $bgColorG = intval(substr($bgColor, 3, 2), 16);
1037                 $bgColorB = intval(substr($bgColor, 5, 2), 16);
1038
1039                 // TrueColorイメージを作成
1040                 $thumb = imagecreatetruecolor($size, $size);
1041                 //$bgcolor = imagecolorallocate($thumb, 255, 255, 255);         // 背景色設定
1042                 $bgcolor = imagecolorallocate($thumb, $bgColorR, $bgColorG, $bgColorB);         // 背景色設定
1043                 imagefill($thumb, 0, 0, $bgcolor);
1044                 
1045                 // 画像リサイズ
1046                 // imagecopyresampledの方がimagecopyresizedよりも画質が良いのでこちらを使用
1047                 if (function_exists("imagecopyresampled")){
1048                         if (!imagecopyresampled($thumb, $image, $x, $y, 0, 0, $n_width, $n_height, $width, $height)){
1049                                 if (!imagecopyresized($thumb, $image, $x, $y, 0, 0, $n_width, $n_height, $width, $height)) return false;
1050                         }
1051                 } else {
1052                         if (!imagecopyresized($thumb, $image, $x, $y, 0, 0, $n_width, $n_height, $width, $height)) return false;
1053                 }
1054
1055                 // 画像出力
1056                 switch ($destType){
1057                         case IMAGETYPE_GIF:
1058                                 $ret = @imagegif($thumb, $destPath, self::IMAGE_QUALITY);
1059                                 break;
1060                         case IMAGETYPE_JPEG:
1061                                 $ret = @imagejpeg($thumb, $destPath, self::IMAGE_QUALITY);
1062                                 break;
1063                         case IMAGETYPE_PNG:
1064                                 $ret = @imagepng($thumb, $destPath, self::IMAGE_QUALITY);
1065                                 break;
1066                 }
1067                 // イメージを破棄
1068                 $ret = imagedestroy($image);
1069                 $ret = imagedestroy($thumb);
1070                 return $ret;
1071         }
1072         /**
1073          * ウォータマーク入り公開画像を作成
1074          *
1075          * @param string $path          元画像ファイルパス
1076          * @param int $type                     元画像の画像タイプ
1077          * @param string $wPath         ウォータマーク画像ファイルパス
1078          * @param int $wType            ウォータマーク画像の画像タイプ
1079          * @param string $destPath      出力画像のパス
1080          * @param int $destType         出力画像の画像タイプ
1081          * @param int $size                     出力画像の縦または横の最大サイズ
1082          * @return bool                         true=成功、false=失敗
1083          */
1084         function createPublicImage($path, $type, $wPath, $wType, $destPath, $destType, $size)
1085         {
1086                 // 画像作成
1087                 switch ($type){
1088                         case IMAGETYPE_GIF:
1089                                 $image = @imagecreatefromgif($path);
1090                                 break;
1091                         case IMAGETYPE_JPEG:
1092                                 $image = @imagecreatefromjpeg($path);
1093                                 break;
1094                         case IMAGETYPE_PNG:
1095                                 $image = @imagecreatefrompng($path);
1096                                 break;
1097                         default:
1098                                 return false;
1099                 }
1100                 
1101                 // 画像サイズ取得
1102                 $width = imagesx($image);
1103                 $height = imagesy($image);
1104                 
1105                 // 出力サイズ取得
1106                 $destWidth = $size;
1107                 $destHeight = $size;
1108                 $imageRatio = $width / $height;
1109                 if ($destWidth / $destHeight > $imageRatio){
1110                         $destWidth = $destHeight * $imageRatio;
1111                 } else {
1112                         $destHeight = $destWidth / $imageRatio;
1113                 }
1114                 // 出力画像作成
1115                 // imagecopyresampledの方がimagecopyresizedよりも画質が良いのでこちらを使用
1116                 $destImage = imagecreatetruecolor($destWidth, $destHeight);
1117                 imagecopyresampled($destImage, $image, 0, 0, 0, 0, $destWidth, $destHeight, $width, $height);
1118                 
1119                 if (!empty(self::$_configArray[photo_mainCommonDef::CF_IMAGE_PROTECT_COPYRIGHT])){      // 著作権保護ありの場合
1120                         // 画像作成
1121                         switch ($wType){
1122                                 case IMAGETYPE_GIF:
1123                                         $wImage = @imagecreatefromgif($wPath);
1124                                         break;
1125                                 case IMAGETYPE_JPEG:
1126                                         $wImage = @imagecreatefromjpeg($wPath);
1127                                         break;
1128                                 case IMAGETYPE_PNG:
1129                                         $wImage = @imagecreatefrompng($wPath);
1130                                         break;
1131                                 default:
1132                                         return false;
1133                         }
1134                 
1135                         // 画像サイズ取得
1136                         $wWidth = imagesx($wImage);
1137                         $wHeight = imagesy($wImage);
1138                 
1139                         $startwidth = ($destWidth - $wWidth) / 2; 
1140                         $startheight = ($destHeight - $wHeight) / 2;
1141                         imagecopymerge($destImage, $wImage, $startwidth, $startheight, 0, 0, $wWidth, $wHeight, 10);
1142                 }
1143                 
1144                 // 画像出力
1145                 switch ($destType){
1146                         case IMAGETYPE_GIF:
1147                                 $ret = @imagegif($destImage, $destPath, self::IMAGE_QUALITY);
1148                                 break;
1149                         case IMAGETYPE_JPEG:
1150                                 $ret = @imagejpeg($destImage, $destPath, self::IMAGE_QUALITY);
1151                                 break;
1152                         case IMAGETYPE_PNG:
1153                                 $ret = @imagepng($destImage, $destPath, self::IMAGE_QUALITY);
1154                                 break;
1155                 }
1156                 // イメージを破棄
1157                 $ret = imagedestroy($destImage);
1158                 $ret = imagedestroy($image);
1159                 if (isset($wImage)) $ret = imagedestroy($wImage);
1160                 return $ret;
1161         }
1162         /**
1163          * 指定数分の画像カテゴリー取得
1164          *
1165          * @param array         $srcRows                        全取得行
1166          * @param int           $categoryCount          取得行数
1167          * @return array                                                取得した行
1168          */
1169         function getCategory($srcRows, $categoryCount)
1170         {
1171                 $destArray = array();
1172                 $itemCount = 0;
1173                 for ($i = 0; $i < count($srcRows); $i++){
1174                         if (!empty($srcRows[$i]['hw_category_id'])){
1175                                 $destArray[] = $srcRows[$i]['hw_category_id'];
1176                                 $itemCount++;
1177                                 if ($itemCount >= $categoryCount) break;
1178                         }
1179                 }
1180                 return $destArray;
1181         }
1182         /**
1183          * 画像カテゴリーメニューを作成
1184          *
1185          * @param array $categoryRows   カテゴリー情報
1186          * @param array $categoryArray  選択中のカテゴリー
1187          * @param int   $size                   メニューの表示数
1188          * @return なし                                               
1189          */
1190         function createCategoryMenu($categoryRows, $categoryArray, $size)
1191         {
1192                 for ($j = 0; $j < $size; $j++){
1193                         // selectメニューの作成
1194                         $this->tmpl->clearTemplate('category_list');
1195                         for ($i = 0; $i < count($categoryRows); $i++){
1196                                 $categoryId = $categoryRows[$i]['hc_id'];
1197                                 $selected = '';
1198                                 if ($j < count($categoryArray) && $categoryArray[$j] == $categoryId){
1199                                         $selected = 'selected';
1200                                 }
1201                                 $menurow = array(
1202                                         'value'         => $categoryId,                 // カテゴリーID
1203                                         'name'          => $categoryRows[$i]['hc_name'],                        // カテゴリー名
1204                                         'selected'      => $selected                                                                                                            // 選択中かどうか
1205                                 );
1206                                 $this->tmpl->addVars('category_list', $menurow);
1207                                 $this->tmpl->parseTemplate('category_list', 'a');
1208                         }
1209                         $itemRow = array(               
1210                                         'index'         => $j                   // 項目番号                                                                                 
1211                         );
1212                         $this->tmpl->addVars('category', $itemRow);
1213                         $this->tmpl->parseTemplate('category', 'a');
1214                 }
1215         }
1216         /**
1217          * 各種画像作成
1218          *
1219          * @param string $photoId                               公開画像ID
1220          * @param string $imagePath                             画像パス
1221          * @param string $originalFilename              オリジナル画像名
1222          * @param string $thumbFilename                 サムネールファイル名(画像情報格納用)
1223          * @return bool                                                 true=成功、失敗
1224          */
1225         function createImages($photoId, $imagePath, $originalFilename, &$thumbFilename)
1226         {
1227                 $ret = true;
1228                 $imageSize = @getimagesize($imagePath);
1229                 if ($imageSize){
1230                         $imageType = $imageSize[2];
1231                 } else {
1232                         return false;
1233                 }
1234                 // ##### システム用サムネール作成 #####
1235 /*              $ret = $this->gInstance->getImageManager()->createDefaultThumb(M3_VIEW_TYPE_PHOTO, $photoId, $imagePath);
1236                 if (!$ret){
1237                         $this->writeError(__METHOD__, 'システム用画像ファイル作成に失敗しました。', 1100,
1238                                                                 '元のファイル名=' . $originalFilename);// 運用ログに記録
1239                 }*/
1240                 $ret = $this->gInstance->getImageManager()->createSystemDefaultThumb(M3_VIEW_TYPE_PHOTO, 0/*PC用*/, $photoId, $imagePath, $destFilename);
1241                 if ($ret){
1242                         $thumbFilename = implode(';', $destFilename);
1243                 } else {
1244                         $this->writeError(__METHOD__, 'システム用画像ファイル作成に失敗しました。', 1100, '元のファイル名=' . $originalFilename);// 運用ログに記録
1245                 }
1246                 
1247                 // ##### サムネール画像作成 #####
1248                 // サムネール画像サイズ取得
1249                 $thumbailSizeArray = trimExplode(',', self::$_configArray[photo_mainCommonDef::CF_THUMBNAIL_SIZE]);
1250                 if (empty($thumbailSizeArray)) $thumbailSizeArray = array(photo_mainCommonDef::DEFAULT_THUMBNAIL_SIZE);
1251                 for ($i = 0; $i < count($thumbailSizeArray); $i++){
1252                         $thumbnailSize = $thumbailSizeArray[$i];
1253                         $thumbnailPath = photo_mainCommonDef::getThumbnailPath($photoId, $thumbnailSize);
1254                         //$ret = $this->createThumbImage($imagePath, $imageType, $thumbnailPath, self::DEFAULT_IMAGE_TYPE, $thumbnailSize);
1255                         if (self::$_configArray[photo_mainCommonDef::CF_THUMBNAIL_CROP]){               // 切り取りサムネールの場合
1256                                 $ret = $this->gInstance->getImageManager()->createThumb($imagePath, $thumbnailPath, $thumbnailSize, self::DEFAULT_IMAGE_TYPE, true);
1257                         } else {
1258                                 $ret = $this->gInstance->getImageManager()->createThumb($imagePath, $thumbnailPath, $thumbnailSize, self::DEFAULT_IMAGE_TYPE, false, self::$_configArray[photo_mainCommonDef::CF_THUMBNAIL_BG_COLOR]);
1259                         }
1260                         if (!$ret){
1261                                 $this->writeError(__METHOD__, '画像ファイル作成に失敗しました。', 1100,
1262                                                                         '元のファイル名=' . $originalFilename . ', 画像ファイル=' . $thumbnailPath);// 運用ログに記録
1263                         }
1264                 }
1265
1266                 // ##### ウォータマーク画像作成 #####
1267                 if ($ret){
1268                         $watermarkPath = $this->gEnv->getCurrentWidgetRootPath() . '/images/default_mark.png';
1269                         $watermarkSize = @getimagesize($watermarkPath);
1270                         if ($watermarkSize) $watermarkType = $watermarkSize[2]; // ファイルタイプを取得
1271                         $imageMaxSize = intval(self::$_configArray[photo_mainCommonDef::CF_DEFAULT_IMAGE_SIZE]);
1272                         if ($imageMaxSize <= 0) $imageMaxSize = photo_mainCommonDef::DEFAULT_IMAGE_SIZE;
1273                         //$ret = $this->createPublicImage($imagePath, $imageType, $watermarkPath, $watermarkType,
1274                         //                                      photo_mainCommonDef::getPublicImagePath($photoId), self::DEFAULT_IMAGE_TYPE, photo_mainCommonDef::DEFAULT_PUBLIC_IMAGE_SIZE);
1275                         $ret = $this->createPublicImage($imagePath, $imageType, $watermarkPath, $watermarkType,
1276                                                                 photo_mainCommonDef::getPublicImagePath($photoId), self::DEFAULT_IMAGE_TYPE, $imageMaxSize);
1277                         if (!$ret){
1278                                 $this->writeError(__METHOD__, '画像ファイル作成に失敗しました。', 1100,
1279                                                                         '元のファイル名=' . $originalFilename . ', 画像ファイル=' . $watermarkPath);// 運用ログに記録
1280                         }
1281                 }
1282                 return $ret;
1283         }
1284         /**
1285          * 各種画像削除
1286          *
1287          * @param array $photoIdArray                   公開画像ID
1288          * @param array $systemFiles                    システム用画像ファイル
1289          * @return bool                                                 true=成功、失敗
1290          */
1291         function deleteImages($photoIdArray, $systemFiles)
1292         {
1293                 $ret = true;
1294                 for ($i = 0; $i < count($photoIdArray); $i++){
1295                         // サムネール削除
1296                         //$thumbnailPath = photo_mainCommonDef::getThumbnailPath($photoIdArray[$i]);
1297                         //if (!@unlink($thumbnailPath)) $ret = false;
1298                         $thumbailSizeArray = trimExplode(',', self::$_configArray[photo_mainCommonDef::CF_THUMBNAIL_SIZE]);
1299                         if (empty($thumbailSizeArray)) $thumbailSizeArray = array(photo_mainCommonDef::DEFAULT_THUMBNAIL_SIZE);
1300                         for ($j = 0; $j < count($thumbailSizeArray); $j++){
1301                                 $thumbnailSize = $thumbailSizeArray[$j];
1302                                 $thumbnailPath = photo_mainCommonDef::getThumbnailPath($photoIdArray[$i], $thumbnailSize);
1303                                 if (!@unlink($thumbnailPath)) $ret = false;
1304                         }
1305                         // 公開画像削除
1306                         $publicImagePath = photo_mainCommonDef::getPublicImagePath($photoIdArray[$i]);
1307                         if (!@unlink($publicImagePath)) $ret = false;
1308                         
1309                         // 作成したシステム用サムネール削除
1310                         $oldFiles = explode(';', $systemFiles[$i]);
1311                         $this->gInstance->getImageManager()->delSystemDefaultThumb(M3_VIEW_TYPE_PHOTO, 0/*PC用*/, $oldFiles);
1312                 }
1313                 return $ret;
1314         }
1315 }
1316 ?>