diff --git a/multimedia/CHANGES.txt b/multimedia/CHANGES.txt index 29bd2c4..cb5bc9d 100644 --- a/multimedia/CHANGES.txt +++ b/multimedia/CHANGES.txt @@ -1,6 +1,13 @@ NetComomns2-multimedia Changelog =============================== +/* FIXME */ +2013/08/28: Version 2.4.0.1 +=============================== +- スマホ対応(Android、iOS) +- IE以外で、一覧表示の状態でチャンネル編集リンクをクリックした際にブロックが表示されなくなるバグを修正 + + 2013/05/20: Version 2.4.0.1 =============================== - ルームのリストア時にタグデータの重複エラーが発生することがあるバグを修正 diff --git a/multimedia/action/main/album/delete/Delete.class.php b/multimedia/action/main/album/delete/Delete.class.php index ca3f34b..a2f98a2 100644 --- a/multimedia/action/main/album/delete/Delete.class.php +++ b/multimedia/action/main/album/delete/Delete.class.php @@ -1,37 +1,37 @@ -multimediaAction->deleteAlbum($this->album['multimedia_id'], $this->album['album_id'])) { - return 'error'; - } - - return 'success'; - } -} -?> +multimediaAction->deleteAlbum($this->album['multimedia_id'], $this->album['album_id'])) { + return 'error'; + } + + return 'success'; + } +} +?> diff --git a/multimedia/action/main/album/entry/Entry.class.php b/multimedia/action/main/album/entry/Entry.class.php index f79b2fd..9f2075a 100644 --- a/multimedia/action/main/album/entry/Entry.class.php +++ b/multimedia/action/main/album/entry/Entry.class.php @@ -1,67 +1,67 @@ -upload_id)) { - $imageSize = $this->multimediaView->getImageSize($this->album_jacket); - } else { - $imageSize = $this->multimediaView->getImageSize($this->upload_id); - } - - $params = array( - "album_name" => $this->album_name, - "upload_id" => $this->upload_id, - "album_jacket" => $this->album_jacket, - "width" => $imageSize[0], - "height" => $imageSize[1], - "album_description" => $this->album_description, - "public_flag" => intval($this->public_flag) - ); - - if (empty($this->album_id)) { - $params["multimedia_id"] = $this->multimedia_id; - $albumSequence = $this->db->maxExecute("multimedia_album", "album_sequence", array("multimedia_id" => $this->multimedia_id)); - $params["album_sequence"] = $albumSequence + 1; - $result = $this->db->insertExecute("multimedia_album", $params, true, "album_id"); - } else { - $result = $this->db->updateExecute("multimedia_album", $params, array("album_id" => $this->album_id), true); - } - if ($result === false) { - return 'error'; - } - - return 'success'; - } -} -?> +upload_id)) { + $imageSize = $this->multimediaView->getImageSize($this->album_jacket); + } else { + $imageSize = $this->multimediaView->getImageSize($this->upload_id); + } + + $params = array( + "album_name" => $this->album_name, + "upload_id" => $this->upload_id, + "album_jacket" => $this->album_jacket, + "width" => $imageSize[0], + "height" => $imageSize[1], + "album_description" => $this->album_description, + "public_flag" => intval($this->public_flag) + ); + + if (empty($this->album_id)) { + $params["multimedia_id"] = $this->multimedia_id; + $albumSequence = $this->db->maxExecute("multimedia_album", "album_sequence", array("multimedia_id" => $this->multimedia_id)); + $params["album_sequence"] = $albumSequence + 1; + $result = $this->db->insertExecute("multimedia_album", $params, true, "album_id"); + } else { + $result = $this->db->updateExecute("multimedia_album", $params, array("album_id" => $this->album_id), true); + } + if ($result === false) { + return 'error'; + } + + return 'success'; + } +} +?> diff --git a/multimedia/action/main/album/jacket/Jacket.class.php b/multimedia/action/main/album/jacket/Jacket.class.php index 04f2c4c..57d685f 100644 --- a/multimedia/action/main/album/jacket/Jacket.class.php +++ b/multimedia/action/main/album/jacket/Jacket.class.php @@ -1,21 +1,21 @@ -uploadsAction->uploads(); - $this->session->setParameter("multimedia_jacket_upload_id", $files[0]["upload_id"]); - - return true; - } -} +uploadsAction->uploads(); + $this->session->setParameter("multimedia_jacket_upload_id", $files[0]["upload_id"]); + + return true; + } +} ?> \ No newline at end of file diff --git a/multimedia/action/main/comment/delete/Delete.class.php b/multimedia/action/main/comment/delete/Delete.class.php index bd6b707..8251dfd 100644 --- a/multimedia/action/main/comment/delete/Delete.class.php +++ b/multimedia/action/main/comment/delete/Delete.class.php @@ -1,40 +1,40 @@ - $this->comment_id - ); - if (!$this->db->deleteExecute("multimedia_comment", $params)) { - return 'error'; - } - - return 'success'; - } -} -?> + $this->comment_id + ); + if (!$this->db->deleteExecute("multimedia_comment", $params)) { + return 'error'; + } + + return 'success'; + } +} +?> diff --git a/multimedia/action/main/comment/entry/Entry.class.php b/multimedia/action/main/comment/entry/Entry.class.php index ff81422..04487db 100644 --- a/multimedia/action/main/comment/entry/Entry.class.php +++ b/multimedia/action/main/comment/entry/Entry.class.php @@ -1,57 +1,57 @@ -comment_id)) { - $params = array( - "item_id" => $this->item['item_id'], - "album_id" => $this->album['album_id'], - "multimedia_id" => $this->album['multimedia_id'], - "comment_value" => $this->comment_value - ); - $result = $this->db->insertExecute("multimedia_comment", $params, true, "comment_id"); - } else { - $params = array( - "comment_id" => $this->comment_id, - "comment_value" => $this->comment_value - ); - $result = $this->db->updateExecute("multimedia_comment", $params, "comment_id", true); - } - if (!$result) { - return 'error'; - } - - return 'success'; - } -} -?> +comment_id)) { + $params = array( + "item_id" => $this->item['item_id'], + "album_id" => $this->album['album_id'], + "multimedia_id" => $this->album['multimedia_id'], + "comment_value" => $this->comment_value + ); + $result = $this->db->insertExecute("multimedia_comment", $params, true, "comment_id"); + } else { + $params = array( + "comment_id" => $this->comment_id, + "comment_value" => $this->comment_value + ); + $result = $this->db->updateExecute("multimedia_comment", $params, "comment_id", true); + } + if (!$result) { + return 'error'; + } + + return 'success'; + } +} +?> diff --git a/multimedia/action/main/item/delete/Delete.class.php b/multimedia/action/main/item/delete/Delete.class.php index 69f449e..d37f8b0 100644 --- a/multimedia/action/main/item/delete/Delete.class.php +++ b/multimedia/action/main/item/delete/Delete.class.php @@ -1,37 +1,37 @@ -multimediaAction->deleteItem($this->item_id)) { - return 'error'; - } - - return 'success'; - } -} +multimediaAction->deleteItem($this->item_id)) { + return 'error'; + } + + return 'success'; + } +} ?> \ No newline at end of file diff --git a/multimedia/action/main/item/edit/Edit.class.php b/multimedia/action/main/item/edit/Edit.class.php index f9cfbf1..40e3368 100644 --- a/multimedia/action/main/item/edit/Edit.class.php +++ b/multimedia/action/main/item/edit/Edit.class.php @@ -1,66 +1,66 @@ - $this->album_id, - "item_name" => $this->item_name, - "item_description" => $this->item_description, - "privacy" => $this->privacy - ); - $where_params = array( - "item_id" => $this->item_id - ); - $result = $this->db->updateExecute("multimedia_item", $params, $where_params, true); - if ($result === false) { - return 'error'; - } - - if($this->album_id != $this->item['album_id']) { - if(!$this->multimediaAction->setItemCount($this->album_id, 1)) { - return 'error'; - } - if(!$this->multimediaAction->setItemCount($this->item['album_id'], -1)) { - return 'error'; - } - } - - if(!empty($this->item_tag)) { - if(!$this->multimediaAction->setItemTag($this->item_id, $this->item_tag)) { - return 'error'; - } - } - - return 'success'; - } -} -?> + $this->album_id, + "item_name" => $this->item_name, + "item_description" => $this->item_description, + "privacy" => $this->privacy + ); + $where_params = array( + "item_id" => $this->item_id + ); + $result = $this->db->updateExecute("multimedia_item", $params, $where_params, true); + if ($result === false) { + return 'error'; + } + + if($this->album_id != $this->item['album_id']) { + if(!$this->multimediaAction->setItemCount($this->album_id, 1)) { + return 'error'; + } + if(!$this->multimediaAction->setItemCount($this->item['album_id'], -1)) { + return 'error'; + } + } + + if(!empty($this->item_tag)) { + if(!$this->multimediaAction->setItemTag($this->item_id, $this->item_tag)) { + return 'error'; + } + } + + return 'success'; + } +} +?> diff --git a/multimedia/action/main/item/play/Play.class.php b/multimedia/action/main/item/play/Play.class.php index 043456c..4cc652d 100644 --- a/multimedia/action/main/item/play/Play.class.php +++ b/multimedia/action/main/item/play/Play.class.php @@ -14,22 +14,21 @@ */ class Multimedia_Action_Main_Item_Play extends Action { - // リクエストパラメータを受け取るため - - // バリデートによりセット - var $item = null; - var $uploadsView = null; - - - // 値をセットするため - - /** - * [[機能説明]] - * - * @access public - */ - function execute() - { + // 使用コンポーネントを受け取るため + var $session = null; + var $uploadsView = null; + var $db = null; + + // バリデートによりセット + var $item = null; + + /** + * [[機能説明]] + * + * @access public + */ + function execute() + { list($pathname,$filename,$physical_file_name, $cache_flag) = $this->uploadsView->downloadCheck($this->item['upload_id'], null); if (!isset($pathname)) { exit; @@ -41,8 +40,113 @@ function execute() $caching = false; } - $this->uploadsView->headerOutput($pathname, $filename, $physical_file_name, $caching); - exit; - } + //Rangeヘッダが設定されている場合(iOS) + if(isset($_SERVER['HTTP_RANGE'])) { + //動画ファイルサイズ取得 + $file = $pathname . $filename; + $file_size = filesize($file) - 1; //Rangeヘッダのオフセットが0であるため、-1 + + //Rangeヘッダを解析 + list($range_header, $range) = explode('=', $_SERVER['HTTP_RANGE']); + list($range_offset, $range_limit) = explode('-', $range); + $playback_session_id_array = array(); + + //Rangeヘッダが0からファイル終端の場合(ファイル存在確認後、1度のみリクエストされる) + if($range_offset == 0 && $range_limit == $file_size - 1) { + //再生回数更新 + $params = array( + $this->item['item_id'] + ); + $sql = "UPDATE {multimedia_item} ". + "SET item_play_count = item_play_count + 1 ". + "WHERE item_id = ? "; + $result = $this->db->execute($sql, $params); + if ($result === false) { + return 'error'; + } + } + + // Rangeヘッダの終了値が省略されている場合はファイルサイズを設定 + if(is_null($range_limit)) { + $range_limit = $file_size; + } + + //Rangeヘッダが指定するコンテンツの長さを設定(Rangeヘッダのオフセットが0であるため、+1) + $content_length = $range_limit - $range_offset + 1; + + //Rangeヘッダで指定された範囲の動画を取得 + $content = file_get_contents($file, FILE_BINARY, null, $range_offset, $range_limit); + + //ヘッダ出力 + @ob_end_clean(); + header('Content-type: video/mp4'); + header('Content-Disposition: attachment; filename="' . $filename . '"'); + header('Content-Transfer-Encoding: binary'); + header('Accept-Ranges: bytes'); + header('HTTP/1.1 206 Partial Content'); + header('Content-Length: ' . $content_length); + header('Content-Range: bytes ' . $range_offset . '-' . $range_limit . '/' . $file_size); +// header("Etag: \"" . md5( $_SERVER["REQUEST_URI"] ) . $file_size . "\"" ); + header("Last-Modified: " . gmdate( "D, d M Y H:i:s", filemtime($file)) . " GMT"); + +// 以下、webapp/components/uploads/View.class.php の function _headerOutput より + $stats = stat($file); + $etag = sprintf( '"%x-%x-%x"', $stats['ino'], $stats['size'], $stats['mtime'] ); + header('Etag: '.$etag); + + if($caching == true) { + // 1Week + header("Cache-Control: max-age=604800, public"); + header('Pragma: cache'); //no-cache以外の文字列をセット + $offset = 60 * 60 * 24 * 7; // 1Week + header('Expires: '.gmdate('D, d M Y H:i:s', time() + $offset).' GMT'); + if (isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && + stripcslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) == $etag ) { + header( 'HTTP/1.1 304 Not Modified' ); + $status_code = "304"; + } + //} else if (isset($_SERVER['HTTPS']) && stristr($_SERVER['HTTP_USER_AGENT'], "MSIE")) { + // // IE + サイト全体SSLの場合、ダウンロードが正常に行われない。 + // // ダウンロードさせるためには、以下コメントをはずす必要があるが、 + // // アップロードした画像ファイル等をローカルキャッシュにとられてしまう弊害がある。 + // // 1Week + // header("Cache-Control: max-age=604800, public"); + // header('Pragma: cache'); //no-cache以外の文字列をセット + // $offset = 60 * 60 * 24 * 7; // 1Week + // header('Expires: '.gmdate('D, d M Y H:i:s', time() + $offset).' GMT'); + } else { + header("Cache-Control: no-store, no-cache, must-revalidate"); + header("Pragma: no-cache"); + } +// 以上、webapp/components/uploads/View.class.php の function _headerOutput より + + //ファイル出力 + $fp = fopen($file, "rb"); + fseek($fp, $range_offset, SEEK_SET); + echo fread($fp, $content_length); + exit; + } + //Rangeヘッダが設定されていない場合 + else { + //HTTP_USER_AGENTが設定されている場合のみ再生数をカウント(Android Chrome対策) + if(isset($_SERVER['HTTP_USER_AGENT'])) { + //再生回数更新 + $params = array( + $this->item['item_id'] + ); + $sql = "UPDATE {multimedia_item} ". + "SET item_play_count = item_play_count + 1 ". + "WHERE item_id = ? "; + $result = $this->db->execute($sql, $params); + if ($result === false) { + return 'error'; + } + } + + //動画出力 + $this->uploadsView->headerOutput($pathname, $filename, $physical_file_name, $caching); + exit; + } + } } ?> \ No newline at end of file diff --git a/multimedia/action/main/item/play/maple.ini b/multimedia/action/main/item/play/maple.ini index 95258cb..40e7c9d 100644 --- a/multimedia/action/main/item/play/maple.ini +++ b/multimedia/action/main/item/play/maple.ini @@ -11,7 +11,7 @@ request = BOTH upload_id.multimedia.playCheck = "1:lang.multimedia_err_incorrectauth" [Action] -actionChain = "ref:ActionChain" +db = "ref:DbObject" uploadsView = "ref:uploadsView" session = "ref:Session" diff --git a/multimedia/action/main/item/sequence/Sequence.class.php b/multimedia/action/main/item/sequence/Sequence.class.php index 05b5cb9..3ca3d7a 100644 --- a/multimedia/action/main/item/sequence/Sequence.class.php +++ b/multimedia/action/main/item/sequence/Sequence.class.php @@ -1,77 +1,77 @@ -album_id, - $this->drag_sequence, - $this->drop_sequence - ); - - if ($this->drag_sequence > $this->drop_sequence) { - $sql = "UPDATE {multimedia_item} ". - "SET item_sequence = item_sequence + 1 ". - "WHERE album_id = ? ". - "AND item_sequence < ? ". - "AND item_sequence > ?"; - } else { - $sql = "UPDATE {multimedia_item} ". - "SET item_sequence = item_sequence - 1 ". - "WHERE album_id = ? ". - "AND item_sequence > ? ". - "AND item_sequence <= ?"; - } - - $result = $this->db->execute($sql, $params); - if($result === false) { - return 'error'; - } - - if ($this->drag_sequence > $this->drop_sequence) { - $this->drop_sequence++; - } - $params = array( - $this->drop_sequence, - $this->drag_item_id - ); - - $sql = "UPDATE {multimedia_item} ". - "SET item_sequence = ? ". - "WHERE item_id = ?"; - $result = $this->db->execute($sql, $params); - if($result === false) { - return 'error'; - } - - return 'success'; - } -} +album_id, + $this->drag_sequence, + $this->drop_sequence + ); + + if ($this->drag_sequence > $this->drop_sequence) { + $sql = "UPDATE {multimedia_item} ". + "SET item_sequence = item_sequence + 1 ". + "WHERE album_id = ? ". + "AND item_sequence < ? ". + "AND item_sequence > ?"; + } else { + $sql = "UPDATE {multimedia_item} ". + "SET item_sequence = item_sequence - 1 ". + "WHERE album_id = ? ". + "AND item_sequence > ? ". + "AND item_sequence <= ?"; + } + + $result = $this->db->execute($sql, $params); + if($result === false) { + return 'error'; + } + + if ($this->drag_sequence > $this->drop_sequence) { + $this->drop_sequence++; + } + $params = array( + $this->drop_sequence, + $this->drag_item_id + ); + + $sql = "UPDATE {multimedia_item} ". + "SET item_sequence = ? ". + "WHERE item_id = ?"; + $result = $this->db->execute($sql, $params); + if($result === false) { + return 'error'; + } + + return 'success'; + } +} ?> \ No newline at end of file diff --git a/multimedia/action/main/item/upload/Upload.class.php b/multimedia/action/main/item/upload/Upload.class.php index cde0f54..a11cdb3 100644 --- a/multimedia/action/main/item/upload/Upload.class.php +++ b/multimedia/action/main/item/upload/Upload.class.php @@ -1,28 +1,28 @@ - \ No newline at end of file diff --git a/multimedia/action/main/item/vote/Vote.class.php b/multimedia/action/main/item/vote/Vote.class.php index 23bdf91..25a7fa6 100644 --- a/multimedia/action/main/item/vote/Vote.class.php +++ b/multimedia/action/main/item/vote/Vote.class.php @@ -1,71 +1,71 @@ -session->getParameter("_user_id"); - - if (empty($user_id)) { - $votes = $this->session->getParameter("multimedia_votes"); - $votes[] = $this->item_id; - $session->setParameter("multimedia_votes", $votes); - } else { - $params = array( - "user_id" => $user_id, - "item_id" => $this->item_id, - "vote_flag" => _ON - ); - if (!$this->db->insertExecute("mutlimedia_user_item", $params, true)) { - return 'error'; - } - } - - $params = array($this->item_id); - $sql = "UPDATE {multimedia_item} ". - "SET item_vote_count = item_vote_count + 1 ". - "WHERE item_id = ?"; - $result = $this->db->execute($sql, $params); - if ($result === false) { - return 'error'; - } - - $params = array($this->album_id); - $sql = "UPDATE {multimedia_album} ". - "SET album_vote_count = album_vote_count + 1 ". - "WHERE album_id = ?"; - $result = $this->db->execute($sql, $params); - if ($result === false) { - return 'error'; - } - - return 'success'; - } -} +session->getParameter("_user_id"); + + if (empty($user_id)) { + $votes = $this->session->getParameter("multimedia_votes"); + $votes[] = $this->item_id; + $session->setParameter("multimedia_votes", $votes); + } else { + $params = array( + "user_id" => $user_id, + "item_id" => $this->item_id, + "vote_flag" => _ON + ); + if (!$this->db->insertExecute("mutlimedia_user_item", $params, true)) { + return 'error'; + } + } + + $params = array($this->item_id); + $sql = "UPDATE {multimedia_item} ". + "SET item_vote_count = item_vote_count + 1 ". + "WHERE item_id = ?"; + $result = $this->db->execute($sql, $params); + if ($result === false) { + return 'error'; + } + + $params = array($this->album_id); + $sql = "UPDATE {multimedia_album} ". + "SET album_vote_count = album_vote_count + 1 ". + "WHERE album_id = ?"; + $result = $this->db->execute($sql, $params); + if ($result === false) { + return 'error'; + } + + return 'success'; + } +} ?> \ No newline at end of file diff --git a/multimedia/components/Action.class.php b/multimedia/components/Action.class.php index 165e255..4b5716a 100644 --- a/multimedia/components/Action.class.php +++ b/multimedia/components/Action.class.php @@ -1,575 +1,631 @@ -_db =& $container->getComponent("DbObject"); - $this->_request =& $container->getComponent("Request"); - } - - function hasFfmpegLib() { - $extension_fullname = PHP_EXTENSION_DIR . "/" . MULTIMEDIA_EXTENSION.".".PHP_SHLIB_SUFFIX; - if (!extension_loaded(MULTIMEDIA_EXTENSION)) { - //dl($extension_soname) or die("Can't load extension $extension_fullname\n"); - return false; - } - return true; - } - - function deleteMultimedia() { - $params = array( - "multimedia_id" => $this->_request->getParameter("multimedia_id") - ); - - if (!$this->_db->deleteExecute("multimedia_block", $params)) { - return false; - } - - if (!$this->_db->deleteExecute("multimedia_comment", $params)) { - return false; - } - - $sql = "SELECT item_id, upload_id, file_path ". - "FROM {multimedia_item} ". - "WHERE multimedia_id = ?"; - $items = $this->_db->execute($sql, $params); - if ($items === false) { - $this->_db->addError(); - return false; - } - if (!$this->deleteItemFile($items)) { - return false; - } - if (!$this->_db->deleteExecute("multimedia_item", $params)) { - return false; - } - if (!$this->_db->deleteExecute("multimedia_album", $params)) { - return false; - } - if (!$this->_db->deleteExecute("multimedia", $params)) { - return false; - } - - return true; - } - - //動画ファイル削除 - function deleteItemFile($items) - { - if (empty($items)) { - return true; - } - - $container =& DIContainerFactory::getContainer(); - $commonMain =& $container->getComponent("commonMain"); - $uploads =& $commonMain->registerClass(WEBAPP_DIR.'/components/uploads/Action.class.php', "Uploads_Action", "uploadsAction"); - $item_ids = array(); - foreach ($items as $item) { - if (!$uploads->delUploadsById($item['upload_id'])) { - return false; - } - //動画のサムネイル画像があれば、削除 - $thumbnail_path = FILEUPLOADS_DIR.$item['file_path'].$item['upload_id']."_thumbnail.jpg"; - if(file_exists($thumbnail_path)) { - @chmod($thumbnail_path, 0777); - unlink($thumbnail_path); - } - //タグ削除 - $sql = "SELECT tag_id " - . "FROM {multimedia_item_tag} " - . "WHERE item_id = ?;"; - $params = array( - "item_id" => $item['item_id'] - ); - $tag_id_string = $this->_db->execute($sql, $params, $limit = null, $offset = null, false, array($this, "_makeImplodeString")); - if ($tag_id_string === false) { - $this->_db->addError(); - return false; - } - if (!empty($tag_id_string)) { - if(!$this->_db->deleteExecute("multimedia_item_tag", $params)) { - return false; - } - } - $this->_tagReCount($tag_id_string); - - if (!$this->_db->deleteExecute("multimedia_item_tag", $params)) { - return false; - } - } - - return true; - } - - //カテゴリ削除 - function deleteAlbum($multimedia_id, $album_id) { - $params = array( - "album_id" => $album_id - ); - - if (!$this->_db->deleteExecute("multimedia_comment", $params)) { - return false; - } - - $sql = "SELECT item_id, upload_id, file_path ". - "FROM {multimedia_item} ". - "WHERE album_id = ?"; - $items = $this->_db->execute($sql, $params); - if ($items === false) { - $this->_db->addError(); - return false; - } - if (!$this->deleteItemFile($items)) { - return false; - } - if (!$this->_db->deleteExecute("multimedia_item", $params)) { - return false; - } - - $sql = "SELECT album_sequence, upload_id ". - "FROM {multimedia_album} ". - "WHERE album_id = ?"; - $albums = $this->_db->execute($sql, $params); - if ($albums === false) { - $this->_db->addError(); - return false; - } - - if (!$this->_db->deleteExecute("multimedia_album", $params)) { - return false; - } - - if(!empty($albums[0]['upload_id'])) { - $container =& DIContainerFactory::getContainer(); - $commonMain =& $container->getComponent("commonMain"); - $uploads =& $commonMain->registerClass(WEBAPP_DIR.'/components/uploads/Action.class.php', "Uploads_Action", "uploadsAction"); - if (!$uploads->delUploadsById($albums[0]['upload_id'])) { - return false; - } - } - - $params = array( - "multimedia_id" => $multimedia_id - ); - $sequenceParam = array( - "album_sequence" => $albums[0]['album_sequence'] - ); - if (!$this->_db->seqExecute("multimedia_album", $params, $sequenceParam)) { - return false; - } - - return true; - } - - //動画削除 - function deleteItem($item_id) { - $params = array( - "item_id" => $item_id - ); - - //コメント削除 - if (!$this->_db->deleteExecute("multimedia_comment", $params)) { - return false; - } - - //動画削除 - $sql = "SELECT item_id, album_id, upload_id, file_path ". - "FROM {multimedia_item} ". - "WHERE item_id = ?"; - $item = $this->_db->execute($sql, $params); - if ($item === false) { - $this->_db->addError(); - return false; - } - if (!$this->deleteItemFile($item)) { - return false; - } - if (!$this->_db->deleteExecute("multimedia_item", $params)) { - return false; - } - - if(!$this->setItemCount($item[0]['album_id'], -1)) { - return false; - } - - return true; - } - - //アルバムの動画件数を計算 - function setItemCount($album_id, $count) { - if(empty($album_id)) { - return false; - } - - $params = array( - "album_id" => $album_id - ); - - $album = $this->_db->selectExecute("multimedia_album", $params); - if(empty($album) || !isset($album[0])) { - return false; - } - - $sql = "UPDATE {multimedia_album} ". - "SET item_count = item_count + ".($count)." ". - "WHERE album_id = ?"; - $result = $this->_db->execute($sql, $params); - if ($result === false) { - $this->_db->addError(); - return false; - } - - return true; - } - - /** - * 動画タグデータを登録する - * - * @param string $item_id 対象の動画ID - * @return boolean true or false - * @access public - */ - function setItemTag($item_id, $item_tag) { - if(empty($item_id)) { - return false; - } - - $container =& DIContainerFactory::getContainer(); - - $tag_values = array(); - if (!empty($item_tag)) { - $item_tag = str_replace(',', MULTIMEDIA_TAG_SEPARATOR, $item_tag); - $item_tag = str_replace('、', MULTIMEDIA_TAG_SEPARATOR, $item_tag); - $item_tag = str_replace('、', MULTIMEDIA_TAG_SEPARATOR, $item_tag); - $tag_values = split(MULTIMEDIA_TAG_SEPARATOR, $item_tag); - } - - foreach ($tag_values as $key => $value) { - $value = preg_replace("/^[ ]+/u","",$value); - $value = preg_replace("/[ ]+$/u","",$value); - $tag_values[$key] = $value; - } - - $tag_values = array_unique($tag_values); - - $sql = "SELECT R.tag_id " - . "FROM {multimedia_item_tag} AS R " - . "INNER JOIN {multimedia_tag} AS T " - . "ON R.tag_id = T.tag_id " - . "WHERE R.item_id = ? "; - $params = array( - $item_id - ); - $tag_id_string = $this->_db->execute($sql, $params, $limit = null, $offset = null, false, array($this, "_makeImplodeString")); - - if ($tag_id_string === false) { - $this->_db->addError(); - return false; - } - if (!empty($tag_id_string)) { - $sql = "DELETE FROM {multimedia_item_tag} " - . "WHERE item_id = ? " - . "AND tag_id IN (" . $tag_id_string . ") "; - $params = array( - $item_id - ); - if ($this->_db->execute($sql, $params) === false) { - $this->_db->addError(); - return false; - } - } - - $sequence = 1; - $tag_ids = array(); - foreach ($tag_values as $tag_value) { - if (empty($tag_value)) { - continue; - } - $sql = "SELECT tag_id " - . "FROM {multimedia_tag} " - . "WHERE tag_value = ? AND room_id = ? "; - $params = array( - $this->getSynonym($tag_value), - $this->_request->getParameter("room_id") - ); - $item_tag_ids = $this->_db->execute($sql, $params); - if ($item_tag_ids === false) { - $this->_db->addError(); - return false; - } - if (empty($item_tag_ids)) { - $params = array( - 'tag_value' => $this->getSynonym($tag_value), - 'used_number' => 1 - ); - - $tag_id = $this->_db->insertExecute('multimedia_tag', $params, true, 'tag_id'); - if (empty($tag_id)) { - return false; - } - - } else { - $tag_id = $item_tag_ids[0]['tag_id']; - } - $tag_ids[] = $tag_id; - - $item_tag = array( - 'item_id' => $item_id, - 'tag_id' => $tag_id, - 'tag_value' => $tag_value, - 'sequence' => $sequence - ); - if (!$this->_db->insertExecute('multimedia_item_tag', $item_tag, true)){ - return false; - } - $sequence++; - } - - if (!empty($tag_id_string) && !empty($tag_ids)) { - $tag_id_string .= ','; - } - $tag_id_string .= implode(',', $tag_ids); - - if (!$this->_tagReCount($tag_id_string)) { - return false; - } - - return true; - } - - /** - * 動画タグの使用回数を再カウント。0件ならmultimedia_tagから削除。 - * - * @param string $tagIDString 区切り文字 - * @return boolean true or false - * @access private - */ - function _tagReCount($tag_id_string) { - $counted_tag_ids = array(); - if (!empty($tag_id_string)) { - $sql = "SELECT tag_id, " - . "COUNT(DISTINCT item_id) AS tag_count " - . "FROM {multimedia_item_tag} " - . "WHERE tag_id IN (" . $tag_id_string . ") " - . "GROUP BY tag_id;"; - $tags = $this->_db->execute($sql); - if ($tags === false) { - $this->_db->addError(); - return false; - } - if(!empty($tags)) { - foreach ($tags as $tag) { - $tag_used_number = array( - 'tag_id' => $tag['tag_id'], - 'used_number' => $tag['tag_count'] - ); - if (!$this->_db->updateExecute('multimedia_tag', $tag_used_number, 'tag_id', true)) { - return false; - } - - $counted_tag_ids[] = $tag['tag_id']; - } - } - } - - $tag_ids = explode(',', $tag_id_string); - $tag_ids = array_diff($tag_ids, $counted_tag_ids); - foreach ($tag_ids as $tag_id) { - $tag_used_number = array( - 'tag_id' => $tag_id - ); - if (!$this->_db->deleteExecute('multimedia_tag', $tag_used_number)) { - return false; - } - } - - return true; - } - - /** - * ADORecordSetの1カラム目を指定文字区切りの文字列にする - * - * @param array $recordSet ADORecordSet - * @param array $glue 区切り文字 - * @return array 指定文字区切りの文字列 - * @access private - */ - function &_makeImplodeString(&$recordSet, $glue = ",") { - $string = ""; - if ($recordSet->EOF) { - return $string; - } - - while ($row = $recordSet->fetchRow()) { - $string .= $row[0] . $glue; - } - if (!empty($glue)) { - $string = substr($string, 0, strlen($glue) * -1); - } - - return $string; - } - - function getSynonym($str) { - //半角カナ(濁点付き)→全角カナに変換 - $replace_of = array('ヴ', 'ガ', 'ギ', 'グ', - 'ゲ', 'ゴ', 'ザ', 'ジ', - 'ズ', 'ゼ', 'ゾ', 'ダ', - 'ヂ', 'ヅ', 'デ', 'ド', - 'バ', 'ビ', 'ブ', 'ベ', - 'ボ', 'パ', 'ピ', 'プ', 'ペ', 'ポ'); - - $replace_by = array('ヴ', 'ガ', 'ギ', 'グ', - 'ゲ', 'ゴ', 'ザ', 'ジ', - 'ズ', 'ゼ', 'ゾ', 'ダ', - 'ヂ', 'ヅ', 'デ', 'ド', - 'バ', 'ビ', 'ブ', 'ベ', - 'ボ', 'パ', 'ピ', 'プ', 'ペ', 'ポ'); - $_result = str_replace($replace_of, $replace_by, $str); - - //半角カナ→全角カナに変換 - $replace_of = array('ア', 'イ', 'ウ', 'エ', 'オ', - 'カ', 'キ', 'ク', 'ケ', 'コ', - 'サ', 'シ', 'ス', 'セ', 'ソ', - 'タ', 'チ', 'ツ', 'テ', 'ト', - 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', - 'ハ', 'ヒ', 'フ', 'ヘ', 'ホ', - 'マ', 'ミ', 'ム', 'メ', 'モ', - 'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', - 'ル', 'レ', 'ロ', 'ワ', 'ヲ', - 'ン', 'ァ', 'ィ', 'ゥ', 'ェ', - 'ォ', 'ヵ', 'ヶ', 'ャ', 'ュ', - 'ョ', 'ッ', '、', '。', 'ー', - '「', '」', '゙', '゚'); - - $replace_by = array('ア', 'イ', 'ウ', 'エ', 'オ', - 'カ', 'キ', 'ク', 'ケ', 'コ', - 'サ', 'シ', 'ス', 'セ', 'ソ', - 'タ', 'チ', 'ツ', 'テ', 'ト', - 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', - 'ハ', 'ヒ', 'フ', 'ヘ', 'ホ', - 'マ', 'ミ', 'ム', 'メ', 'モ', - 'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', - 'ル', 'レ', 'ロ', 'ワ', 'ヲ', - 'ン', 'ァ', 'ィ', 'ゥ', 'ェ', - 'ォ', 'ヶ', 'ヶ', 'ャ', 'ュ', - 'ョ', 'ッ', '、', '。', 'ー', - '「', '」', '”', ''); - - $_result = str_replace($replace_of, $replace_by, $_result); - - //全角数字→半角数字に変換 - $replace_of = array('1', '2', '3', '4', '5', - '6', '7', '8', '9', '0'); - - $replace_by = array('1', '2', '3', '4', '5', - '6', '7', '8', '9', '0'); - - $_result = str_replace($replace_of, $replace_by, $_result); - - //全角英字→半角英字に変換 - $replace_of = array('A', 'B', 'C', 'D', 'E', - 'F', 'G', 'H', 'I', 'J', - 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', - 'U', 'V', 'W', 'X', 'Y', - 'Z', - 'a', 'b', 'c', 'd', 'e', - 'f', 'g', 'h', 'i', 'j', - 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', - 'u', 'v', 'w', 'x', 'y', - 'z'); - - $replace_by = array('A', 'B', 'C', 'D', 'E', - 'F', 'G', 'H', 'I', 'J', - 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', - 'U', 'V', 'W', 'X', 'Y', - 'Z', - 'a', 'b', 'c', 'd', 'e', - 'f', 'g', 'h', 'i', 'j', - 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', - 'u', 'v', 'w', 'x', 'y', - 'z'); - - $_result = str_replace($replace_of, $replace_by, $_result); - -/* - //小文字ひらがな→小文字カナに変換 - $replace_of = array('ぁ', 'ぃ', 'ぅ', 'ぇ', 'ぉ', - 'ゃ', 'ゅ', 'ょ', 'っ'); - - $replace_by = array('ァ', 'ィ', 'ゥ', 'ェ', 'ォ', - 'ャ', 'ュ', 'ョ', 'ッ'); - - $_result = str_replace($replace_of, $replace_by, $_result); -*/ - //その他記号に変換 - $replace_of = array('ー', '-', '-', '~', ',', - '、', ',', '・', '・', '=', - '=', ' ', ' ', '。', '.', - '.', '/', '/', '―', '‐', - '’', '′', '´', '‘', '゜', - '\'', '"', '〝', '″', '゛', - '“', '”', 'ッ', 'ュ', 'ィ', - 'ゅ', 'ぃ'); - - $replace_by = array('', '', '', '', '', - '', '', '', '', '', - '', '', '', '', '', - '', '', '', '', '', - '', '', '', '', '', - '', '', '', '', '', - '', '', '', '', '', - '', ''); - - $_result = str_replace($replace_of, $replace_by, $_result); - -/* - //小文字カナ→大文字カナに変換 - $replace_of = array('ァ', 'ィ', 'ゥ', 'ェ', 'ォ', - 'ヶ', 'ヶ', 'ャ', 'ュ', 'ョ', 'ッ'); - - $replace_by = array('ア', 'イ', 'ウ', 'エ', 'オ', - 'ケ', 'ケ', 'ヤ', 'ユ', 'ヨ', 'ツ'); - - $_result = str_replace($replace_of, $replace_by, $_result); -*/ - return $_result; - } -} +_db =& $container->getComponent("DbObject"); + $this->_request =& $container->getComponent("Request"); + } + + /** + * ffmpegインストールチェック処理 + * + * @param void + * @return boolean true or false + * @access public + */ + function hasFfmpeg() { + if (!file_exists(MULTIMEDIA_FFMPEG_PATH)) { + return false; + } + return true; + } + + /** + * MP4Bpxインストールチェック処理 + * + * @param void + * @return boolean true or false + * @access public + */ + function hasMp4box() { + if (!file_exists(MULTIMEDIA_MP4BOX_PATH)) { + return false; + } + return true; + } + + /** + * サムネイル画像及び仮サムネイル画像削除処理 + * + * @param string $thumbnail_path サムネイル画像のパス(縮小後) + * @param string $temp_thumbnail_path キャプチャ画像のパス(縮小前) + * @return void + * @access public + */ +# function deleteImages($thumbnail_path, $temp_thumbnail_path) { +# //画像削除 +# unlink($thumbnail_path); +# unlink($temp_thumbnail_path); +# } + + /** + * ファイル削除処理 + * + * @param array $image_paths 削除対象ファイルパス + * @return void + * @access public + */ + function deleteFiles($file_paths) { + foreach($file_paths as $path) { + //ファイル削除 + unlink($path); + } + } + + function hasFfmpegLib() { + $extension_fullname = PHP_EXTENSION_DIR . "/" . MULTIMEDIA_EXTENSION.".".PHP_SHLIB_SUFFIX; + if (!extension_loaded(MULTIMEDIA_EXTENSION)) { + //dl($extension_soname) or die("Can't load extension $extension_fullname\n"); + return false; + } + return true; + } + + function deleteMultimedia() { + $params = array( + "multimedia_id" => $this->_request->getParameter("multimedia_id") + ); + + if (!$this->_db->deleteExecute("multimedia_block", $params)) { + return false; + } + + if (!$this->_db->deleteExecute("multimedia_comment", $params)) { + return false; + } + + $sql = "SELECT item_id, upload_id, file_path ". + "FROM {multimedia_item} ". + "WHERE multimedia_id = ?"; + $items = $this->_db->execute($sql, $params); + if ($items === false) { + $this->_db->addError(); + return false; + } + if (!$this->deleteItemFile($items)) { + return false; + } + if (!$this->_db->deleteExecute("multimedia_item", $params)) { + return false; + } + if (!$this->_db->deleteExecute("multimedia_album", $params)) { + return false; + } + if (!$this->_db->deleteExecute("multimedia", $params)) { + return false; + } + + return true; + } + + //動画ファイル削除 + function deleteItemFile($items) + { + if (empty($items)) { + return true; + } + + $container =& DIContainerFactory::getContainer(); + $commonMain =& $container->getComponent("commonMain"); + $uploads =& $commonMain->registerClass(WEBAPP_DIR.'/components/uploads/Action.class.php', "Uploads_Action", "uploadsAction"); + $item_ids = array(); + foreach ($items as $item) { + if (!$uploads->delUploadsById($item['upload_id'])) { + return false; + } + //動画のサムネイル画像があれば、削除 + $thumbnail_path = FILEUPLOADS_DIR.$item['file_path'].$item['upload_id']."_thumbnail.jpg"; + if(file_exists($thumbnail_path)) { + @chmod($thumbnail_path, 0777); + unlink($thumbnail_path); + } + //タグ削除 + $sql = "SELECT tag_id " + . "FROM {multimedia_item_tag} " + . "WHERE item_id = ?;"; + $params = array( + "item_id" => $item['item_id'] + ); + $tag_id_string = $this->_db->execute($sql, $params, $limit = null, $offset = null, false, array($this, "_makeImplodeString")); + if ($tag_id_string === false) { + $this->_db->addError(); + return false; + } + if (!empty($tag_id_string)) { + if(!$this->_db->deleteExecute("multimedia_item_tag", $params)) { + return false; + } + } + $this->_tagReCount($tag_id_string); + + if (!$this->_db->deleteExecute("multimedia_item_tag", $params)) { + return false; + } + } + + return true; + } + + //カテゴリ削除 + function deleteAlbum($multimedia_id, $album_id) { + $params = array( + "album_id" => $album_id + ); + + if (!$this->_db->deleteExecute("multimedia_comment", $params)) { + return false; + } + + $sql = "SELECT item_id, upload_id, file_path ". + "FROM {multimedia_item} ". + "WHERE album_id = ?"; + $items = $this->_db->execute($sql, $params); + if ($items === false) { + $this->_db->addError(); + return false; + } + if (!$this->deleteItemFile($items)) { + return false; + } + if (!$this->_db->deleteExecute("multimedia_item", $params)) { + return false; + } + + $sql = "SELECT album_sequence, upload_id ". + "FROM {multimedia_album} ". + "WHERE album_id = ?"; + $albums = $this->_db->execute($sql, $params); + if ($albums === false) { + $this->_db->addError(); + return false; + } + + if (!$this->_db->deleteExecute("multimedia_album", $params)) { + return false; + } + + if(!empty($albums[0]['upload_id'])) { + $container =& DIContainerFactory::getContainer(); + $commonMain =& $container->getComponent("commonMain"); + $uploads =& $commonMain->registerClass(WEBAPP_DIR.'/components/uploads/Action.class.php', "Uploads_Action", "uploadsAction"); + if (!$uploads->delUploadsById($albums[0]['upload_id'])) { + return false; + } + } + + $params = array( + "multimedia_id" => $multimedia_id + ); + $sequenceParam = array( + "album_sequence" => $albums[0]['album_sequence'] + ); + if (!$this->_db->seqExecute("multimedia_album", $params, $sequenceParam)) { + return false; + } + + return true; + } + + //動画削除 + function deleteItem($item_id) { + $params = array( + "item_id" => $item_id + ); + + //コメント削除 + if (!$this->_db->deleteExecute("multimedia_comment", $params)) { + return false; + } + + //動画削除 + $sql = "SELECT item_id, album_id, upload_id, file_path ". + "FROM {multimedia_item} ". + "WHERE item_id = ?"; + $item = $this->_db->execute($sql, $params); + if ($item === false) { + $this->_db->addError(); + return false; + } + if (!$this->deleteItemFile($item)) { + return false; + } + if (!$this->_db->deleteExecute("multimedia_item", $params)) { + return false; + } + + if(!$this->setItemCount($item[0]['album_id'], -1)) { + return false; + } + + return true; + } + + //アルバムの動画件数を計算 + function setItemCount($album_id, $count) { + if(empty($album_id)) { + return false; + } + + $params = array( + "album_id" => $album_id + ); + + $album = $this->_db->selectExecute("multimedia_album", $params); + if(empty($album) || !isset($album[0])) { + return false; + } + + $sql = "UPDATE {multimedia_album} ". + "SET item_count = item_count + ".($count)." ". + "WHERE album_id = ?"; + $result = $this->_db->execute($sql, $params); + if ($result === false) { + $this->_db->addError(); + return false; + } + + return true; + } + + /** + * 動画タグデータを登録する + * + * @param string $item_id 対象の動画ID + * @return boolean true or false + * @access public + */ + function setItemTag($item_id, $item_tag) { + if(empty($item_id)) { + return false; + } + + $container =& DIContainerFactory::getContainer(); + + $tag_values = array(); + if (!empty($item_tag)) { + $item_tag = str_replace(',', MULTIMEDIA_TAG_SEPARATOR, $item_tag); + $item_tag = str_replace('、', MULTIMEDIA_TAG_SEPARATOR, $item_tag); + $item_tag = str_replace('、', MULTIMEDIA_TAG_SEPARATOR, $item_tag); + $tag_values = split(MULTIMEDIA_TAG_SEPARATOR, $item_tag); + } + + foreach ($tag_values as $key => $value) { + $value = preg_replace("/^[ ]+/u","",$value); + $value = preg_replace("/[ ]+$/u","",$value); + $tag_values[$key] = $value; + } + + $tag_values = array_unique($tag_values); + + $sql = "SELECT R.tag_id " + . "FROM {multimedia_item_tag} AS R " + . "INNER JOIN {multimedia_tag} AS T " + . "ON R.tag_id = T.tag_id " + . "WHERE R.item_id = ? "; + $params = array( + $item_id + ); + $tag_id_string = $this->_db->execute($sql, $params, $limit = null, $offset = null, false, array($this, "_makeImplodeString")); + + if ($tag_id_string === false) { + $this->_db->addError(); + return false; + } + if (!empty($tag_id_string)) { + $sql = "DELETE FROM {multimedia_item_tag} " + . "WHERE item_id = ? " + . "AND tag_id IN (" . $tag_id_string . ") "; + $params = array( + $item_id + ); + if ($this->_db->execute($sql, $params) === false) { + $this->_db->addError(); + return false; + } + } + + $sequence = 1; + $tag_ids = array(); + foreach ($tag_values as $tag_value) { + if (empty($tag_value)) { + continue; + } + $sql = "SELECT tag_id " + . "FROM {multimedia_tag} " + . "WHERE tag_value = ? AND room_id = ? "; + $params = array( + $this->getSynonym($tag_value), + $this->_request->getParameter("room_id") + ); + $item_tag_ids = $this->_db->execute($sql, $params); + if ($item_tag_ids === false) { + $this->_db->addError(); + return false; + } + if (empty($item_tag_ids)) { + $params = array( + 'tag_value' => $this->getSynonym($tag_value), + 'used_number' => 1 + ); + + $tag_id = $this->_db->insertExecute('multimedia_tag', $params, true, 'tag_id'); + if (empty($tag_id)) { + return false; + } + + } else { + $tag_id = $item_tag_ids[0]['tag_id']; + } + $tag_ids[] = $tag_id; + + $item_tag = array( + 'item_id' => $item_id, + 'tag_id' => $tag_id, + 'tag_value' => $tag_value, + 'sequence' => $sequence + ); + if (!$this->_db->insertExecute('multimedia_item_tag', $item_tag, true)){ + return false; + } + $sequence++; + } + + if (!empty($tag_id_string) && !empty($tag_ids)) { + $tag_id_string .= ','; + } + $tag_id_string .= implode(',', $tag_ids); + + if (!$this->_tagReCount($tag_id_string)) { + return false; + } + + return true; + } + + /** + * 動画タグの使用回数を再カウント。0件ならmultimedia_tagから削除。 + * + * @param string $tagIDString 区切り文字 + * @return boolean true or false + * @access private + */ + function _tagReCount($tag_id_string) { + $counted_tag_ids = array(); + if (!empty($tag_id_string)) { + $sql = "SELECT tag_id, " + . "COUNT(DISTINCT item_id) AS tag_count " + . "FROM {multimedia_item_tag} " + . "WHERE tag_id IN (" . $tag_id_string . ") " + . "GROUP BY tag_id;"; + $tags = $this->_db->execute($sql); + if ($tags === false) { + $this->_db->addError(); + return false; + } + if(!empty($tags)) { + foreach ($tags as $tag) { + $tag_used_number = array( + 'tag_id' => $tag['tag_id'], + 'used_number' => $tag['tag_count'] + ); + if (!$this->_db->updateExecute('multimedia_tag', $tag_used_number, 'tag_id', true)) { + return false; + } + + $counted_tag_ids[] = $tag['tag_id']; + } + } + } + + $tag_ids = explode(',', $tag_id_string); + $tag_ids = array_diff($tag_ids, $counted_tag_ids); + foreach ($tag_ids as $tag_id) { + $tag_used_number = array( + 'tag_id' => $tag_id + ); + if (!$this->_db->deleteExecute('multimedia_tag', $tag_used_number)) { + return false; + } + } + + return true; + } + + /** + * ADORecordSetの1カラム目を指定文字区切りの文字列にする + * + * @param array $recordSet ADORecordSet + * @param array $glue 区切り文字 + * @return array 指定文字区切りの文字列 + * @access private + */ + function &_makeImplodeString(&$recordSet, $glue = ",") { + $string = ""; + if ($recordSet->EOF) { + return $string; + } + + while ($row = $recordSet->fetchRow()) { + $string .= $row[0] . $glue; + } + if (!empty($glue)) { + $string = substr($string, 0, strlen($glue) * -1); + } + + return $string; + } + + function getSynonym($str) { + //半角カナ(濁点付き)→全角カナに変換 + $replace_of = array('ヴ', 'ガ', 'ギ', 'グ', + 'ゲ', 'ゴ', 'ザ', 'ジ', + 'ズ', 'ゼ', 'ゾ', 'ダ', + 'ヂ', 'ヅ', 'デ', 'ド', + 'バ', 'ビ', 'ブ', 'ベ', + 'ボ', 'パ', 'ピ', 'プ', 'ペ', 'ポ'); + + $replace_by = array('ヴ', 'ガ', 'ギ', 'グ', + 'ゲ', 'ゴ', 'ザ', 'ジ', + 'ズ', 'ゼ', 'ゾ', 'ダ', + 'ヂ', 'ヅ', 'デ', 'ド', + 'バ', 'ビ', 'ブ', 'ベ', + 'ボ', 'パ', 'ピ', 'プ', 'ペ', 'ポ'); + $_result = str_replace($replace_of, $replace_by, $str); + + //半角カナ→全角カナに変換 + $replace_of = array('ア', 'イ', 'ウ', 'エ', 'オ', + 'カ', 'キ', 'ク', 'ケ', 'コ', + 'サ', 'シ', 'ス', 'セ', 'ソ', + 'タ', 'チ', 'ツ', 'テ', 'ト', + 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', + 'ハ', 'ヒ', 'フ', 'ヘ', 'ホ', + 'マ', 'ミ', 'ム', 'メ', 'モ', + 'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', + 'ル', 'レ', 'ロ', 'ワ', 'ヲ', + 'ン', 'ァ', 'ィ', 'ゥ', 'ェ', + 'ォ', 'ヵ', 'ヶ', 'ャ', 'ュ', + 'ョ', 'ッ', '、', '。', 'ー', + '「', '」', '゙', '゚'); + + $replace_by = array('ア', 'イ', 'ウ', 'エ', 'オ', + 'カ', 'キ', 'ク', 'ケ', 'コ', + 'サ', 'シ', 'ス', 'セ', 'ソ', + 'タ', 'チ', 'ツ', 'テ', 'ト', + 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', + 'ハ', 'ヒ', 'フ', 'ヘ', 'ホ', + 'マ', 'ミ', 'ム', 'メ', 'モ', + 'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', + 'ル', 'レ', 'ロ', 'ワ', 'ヲ', + 'ン', 'ァ', 'ィ', 'ゥ', 'ェ', + 'ォ', 'ヶ', 'ヶ', 'ャ', 'ュ', + 'ョ', 'ッ', '、', '。', 'ー', + '「', '」', '”', ''); + + $_result = str_replace($replace_of, $replace_by, $_result); + + //全角数字→半角数字に変換 + $replace_of = array('1', '2', '3', '4', '5', + '6', '7', '8', '9', '0'); + + $replace_by = array('1', '2', '3', '4', '5', + '6', '7', '8', '9', '0'); + + $_result = str_replace($replace_of, $replace_by, $_result); + + //全角英字→半角英字に変換 + $replace_of = array('A', 'B', 'C', 'D', 'E', + 'F', 'G', 'H', 'I', 'J', + 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', + 'U', 'V', 'W', 'X', 'Y', + 'Z', + 'a', 'b', 'c', 'd', 'e', + 'f', 'g', 'h', 'i', 'j', + 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', + 'u', 'v', 'w', 'x', 'y', + 'z'); + + $replace_by = array('A', 'B', 'C', 'D', 'E', + 'F', 'G', 'H', 'I', 'J', + 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', + 'U', 'V', 'W', 'X', 'Y', + 'Z', + 'a', 'b', 'c', 'd', 'e', + 'f', 'g', 'h', 'i', 'j', + 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', + 'u', 'v', 'w', 'x', 'y', + 'z'); + + $_result = str_replace($replace_of, $replace_by, $_result); + +/* + //小文字ひらがな→小文字カナに変換 + $replace_of = array('ぁ', 'ぃ', 'ぅ', 'ぇ', 'ぉ', + 'ゃ', 'ゅ', 'ょ', 'っ'); + + $replace_by = array('ァ', 'ィ', 'ゥ', 'ェ', 'ォ', + 'ャ', 'ュ', 'ョ', 'ッ'); + + $_result = str_replace($replace_of, $replace_by, $_result); +*/ + //その他記号に変換 + $replace_of = array('ー', '-', '-', '~', ',', + '、', ',', '・', '・', '=', + '=', ' ', ' ', '。', '.', + '.', '/', '/', '―', '‐', + '’', '′', '´', '‘', '゜', + '\'', '"', '〝', '″', '゛', + '“', '”', 'ッ', 'ュ', 'ィ', + 'ゅ', 'ぃ'); + + $replace_by = array('', '', '', '', '', + '', '', '', '', '', + '', '', '', '', '', + '', '', '', '', '', + '', '', '', '', '', + '', '', '', '', '', + '', '', '', '', '', + '', ''); + + $_result = str_replace($replace_of, $replace_by, $_result); + +/* + //小文字カナ→大文字カナに変換 + $replace_of = array('ァ', 'ィ', 'ゥ', 'ェ', 'ォ', + 'ヶ', 'ヶ', 'ャ', 'ュ', 'ョ', 'ッ'); + + $replace_by = array('ア', 'イ', 'ウ', 'エ', 'オ', + 'ケ', 'ケ', 'ヤ', 'ユ', 'ヨ', 'ツ'); + + $_result = str_replace($replace_of, $replace_by, $_result); +*/ + return $_result; + } +} ?> \ No newline at end of file diff --git a/multimedia/components/View.class.php b/multimedia/components/View.class.php index 89c36c7..c65f307 100644 --- a/multimedia/components/View.class.php +++ b/multimedia/components/View.class.php @@ -1,966 +1,966 @@ -_db =& $container->getComponent("DbObject"); - $this->_request =& $container->getComponent("Request"); - $this->_session =& $container->getComponent("Session"); - } - - /** - * 配置されている動画配信IDを取得する - * - * @return string 配置されている動画配信ID - * @access public - */ - function &getCurrentMultimediaId() { - $params = array($this->_request->getParameter("block_id")); - $sql = "SELECT multimedia_id ". - "FROM {multimedia_block} ". - "WHERE block_id = ?"; - $result = $this->_db->execute($sql, $params); - if ($result === false) { - $this->_db->addError(); - return $result; - } - - return $result[0]["multimedia_id"]; - } - - /** - * 現在登録されている動画配信IDを取得する - * - * @return string 配置されている動画配信ID - * @access pblic - */ - function &getFirstMultimediaId() { - $params = array( - $this->_request->getParameter('room_id') - ); - $sql = "SELECT multimedia_id " - . "FROM {multimedia} " - . "WHERE room_id = ?"; - $result = $this->_db->execute($sql, $params, 1); - if ($result === false) { - $this->_db->addError(); - return $result; - } - - return $result[0]['multimedia_id']; - } - - /** - * 動画配信が配置されているブロックデータを取得する - * - * @return string ブロックデータ - * @access public - */ - function &getBlock() { - $params = array($this->_request->getParameter("multimedia_id")); - $sql = "SELECT M.room_id, B.block_id ". - "FROM {multimedia} M ". - "INNER JOIN {multimedia_block} B ". - "ON M.multimedia_id = B.multimedia_id ". - "WHERE M.multimedia_id = ? ". - "ORDER BY B.block_id"; - $result = $this->_db->execute($sql, $params, 1); - if ($result === false) { - $this->_db->addError(); - return $result; - } - - return $result[0]; - } - - /** - * 動画配信が存在するか判断する - * - * @return boolean true:存在する、false:存在しない - * @access public - */ - function multimediaExist() { - $params = array( - $this->_request->getParameter("multimedia_id"), - $this->_request->getParameter("room_id") - ); - $sql = "SELECT multimedia_id ". - "FROM {multimedia} ". - "WHERE multimedia_id = ? ". - "AND room_id = ?"; - $result = $this->_db->execute($sql, $params); - if ($result === false) { - $this->_db->addError(); - return $result; - } - - if (count($result) > 0) { - return true; - } - - return false; - } - - function getMultimediaCount() { - $params["room_id"] = $this->_request->getParameter("room_id"); - $count = $this->_db->countExecute("multimedia", $params); - if($count === false) { - $this->_db->addError(); - } - - return $count; - } - - /** - * 動画配信の設定データを取得する - * - * @return string 設定データ配列 - * @access public - */ - function &getConfig() { - $container =& DIContainerFactory::getContainer(); - $configView =& $container->getComponent("configView"); - $module_id = $this->_request->getParameter("module_id"); - $config = $configView->getConfig($module_id, false); - - return $config; - } - - /** - * 動画配信用デフォルトデータを取得する - * - * @return array 動画配信用デフォルトデータ配列 - * @access public - */ - function &getDefaultMultimedia() { - $config = $this->getConfig(); - if ($config === false) { - return $config; - } - - $multimedia = array( - "album_authority" => constant($config['album_authority']['conf_value']), - "vote_flag" => constant($config['vote_flag']['conf_value']), - "comment_flag" => constant($config['comment_flag']['conf_value']), - "confirm_flag" => constant($config['confirm_flag']['conf_value']), - "display" => constant($config['display']['conf_value']), - "autoplay_flag" => constant($config['autoplay_flag']['conf_value']), - "buffer_time" => $config['buffer_time']['conf_value'], - "album_visible_row" => $config['album_visible_row']['conf_value'], - "new_period" => $config['new_period']['conf_value'], - "album_jacket" => $config['album_jacket']['conf_value'] - ); - - return $multimedia; - } - - /** - * 動画配信データを取得する - * - * @return array 動画配信データ - * @access public - */ - function &getCurrentMultimedia() { - $params = array($this->_request->getParameter("block_id")); - $sql = "SELECT B.block_id, B.multimedia_id, B.display, ". - "B.autoplay_flag, B.buffer_time, ". - "B.album_visible_row, B.new_period, ". - "M.album_authority, M.vote_flag, M.comment_flag, M.confirm_flag ". - "FROM {multimedia_block} B ". - "INNER JOIN {multimedia} M ". - "ON B.multimedia_id = M.multimedia_id ". - "WHERE block_id = ?"; - $result = $this->_db->execute($sql, $params); - if ($result === false) { - $this->_db->addError(); - } - if (empty($result)) { - return $result; - } - - $result[0]['album_authority'] = $this->_hasAlbumAuthority($result[0]); - $result[0]['new_period_time'] = $this->_getNewPeriodTime($result[0]['new_period']); - - return $result[0]; - } - - /** - * アルバム作成権限を取得する - * - * @param array $photoalbum フォトアルバムデータ配列 - * @return boolean true:権限有り、false:権限無し - * @access public - */ - function _hasAlbumAuthority($multimedia) { - $auth_id = $this->_session->getParameter("_auth_id"); - if ($auth_id >= $multimedia['album_authority']) { - return true; - } - - return false; - } - - function getMultimediaById($multimedia_id) { - $params = array( - "multimedia_id" => $multimedia_id - ); - - $result = $this->_db->selectExecute("multimedia", $params); - if ($result === false) { - $this->_db->addError(); - } - - if(!empty($result) && isset($result[0])) { - return $result[0]; - } - - return $result; - } - - /** - * フォトアルバムデータを取得する - * - * @return array フォトアルバムデータ - * @access public - */ - function &getMultimedia() { - $params = array($this->_request->getParameter("multimedia_id")); - $sql = "SELECT multimedia_id, album_authority, vote_flag, comment_flag, confirm_flag ". - "FROM {multimedia} ". - "WHERE multimedia_id = ?"; - $result = $this->_db->execute($sql, $params); - if ($result === false) { - $this->_db->addError(); - return $result; - } - - return $result[0]; - } - - /** - * new記号表示期間から対象年月日を取得する - * - * @param string $new_period new記号表示期間 - * @return string new記号表示対象年月日(YmdHis) - * @access public - */ - function &_getNewPeriodTime($new_period) { - if (empty($new_period)) { - $new_period = -1; - } - - $time = timezone_date(); - $time = mktime(0, 0, 0, - intval(substr($time, 4, 2)), - intval(substr($time, 6, 2)) - $new_period, - intval(substr($time, 0, 4)) - ); - $time = date("YmdHis", $time); - - return $time; - } - - /** - * 動画配信のアルバムの計数を取得する - * - * @param string $new_period new記号表示期間 - * @return string new記号表示対象年月日(YmdHis) - * @access public - */ - function getAlbumCount($multimedia_id) { - $params[] = $multimedia_id; - - $sql = "SELECT COUNT(*) as count ". - "FROM {multimedia_album} A "; - $sql .= $this->_getAuthorityFromSQL(); - $sql .= "WHERE A.multimedia_id = ? "; - $sql .= $this->_getAuthorityWhereSQL($params); - if(!empty($order_params)) { - $sql .= $this->_db->getOrderSQL($order_params); - } - $result = $this->_db->execute($sql, $params); - if ( $result === false ) { - // エラーが発生した場合、エラーリストに追加 - $this->_db->addError(); - return $result; - } - return $result[0]['count']; - } - - /** - * アルバム一覧を取得する - * - * @return array アルバム一覧データ - * @access public - */ - function getAlbumList($multimedia_id, $order_params=null, $disp_cnt=null, $begin=null) { - $params[] = $multimedia_id; - - $sql = "SELECT A.* ". - "FROM {multimedia_album} A "; - $sql .= $this->_getAuthorityFromSQL(); - $sql .= "WHERE A.multimedia_id = ? "; - $sql .= $this->_getAuthorityWhereSQL($params); - if(!empty($order_params)) { - $sql .= $this->_db->getOrderSQL($order_params); - } - $result = $this->_db->execute($sql, $params, $disp_cnt, $begin, true, array($this, "_makeAlbumArray")); - if ( $result === false ) { - // エラーが発生した場合、エラーリストに追加 - $this->_db->addError(); - } - - return $result; - } - - /** - * アルバムデータ配列を生成する - * - * @param array $recordSet タスクADORecordSet - * @return array タスクデータ配列 - * @access private - */ - function &_makeAlbumArray(&$recordSet) { - $multimedia = $this->_request->getParameter("multimedia_obj"); - - $albums = array(); - while ($row = $recordSet->fetchRow()) { - if (!empty($row["album_jacket"])) { - $row["jacket_style"] = $this->getImageStyle($row["width"], $row["height"], MULTIMEDIA_JACKET_WIDTH, MULTIMEDIA_JACKET_HEIGHT); - } - - $row["edit_authority"] = false; - if ($multimedia["album_authority"] - && $this->_hasEditAuthority($row["insert_user_id"])) { - $row["edit_authority"] = true; - } - - $albums[] = $row; - } - - return $albums; - } - - /** - * アルバムのサムネイルのスタイル属性値を取得する - * - * @param string $width 幅 - * @param string $height 高さ - * @param string $maxWidth 最大幅 - * @param string $maxHeight 最大高さ - * @return array 画像のスタイル属性値 - * @access private - */ - function &getImageStyle($width, $height, $maxWidth, $maxHeight) { - $ratio = $height / $width; - - $widthRatio = $width / $maxWidth; - $heightRatio = $height / $maxHeight; - - if ($widthRatio > $heightRatio) { - $height = $maxHeight; - $widht = intval($height / $ratio); - $top = 0; - $right = intval(($widht + $maxWidth) / 2); - $bottom = $maxHeight; - $left = intval(($widht - $maxWidth) / 2); - $marginLeft = $left * -1; - $marginTop = $top; - } else { - $widht = $maxWidth; - $height = intval($widht * $ratio); - $top = intval(($height - $maxHeight) / 2); - $right = $maxWidth; - $bottom = intval(($height + $maxHeight) / 2); - $left = 0; - $marginLeft = $left; - $marginTop = $top * -1; - } - - $style = sprintf(MULTIMEDIA_THUMBNAIL_STYLE, $widht, $height, $top, $right, $bottom, $left, $marginLeft, $marginTop); - - return $style; - } - - /** - * アルバムを取得する - * - * @return array アルバムデータ - * @access public - */ - function getAlbum($album_id) { - $params = array( - "album_id" => intval($album_id) - ); - - $result = $this->_db->selectExecute("multimedia_album", $params, null, null, null, array($this, "_makeAlbumArray")); - if ($result === false) { - $this->_db->addError(); - } - - if(!empty($result) && isset($result[0])) { - return $result[0]; - } - - return $result; - } - - /** - * 動画を取得する - * - * @return array 動画データ - * @access public - */ - function getItem($item_id) { - $params = array( - "item_id" => intval($item_id) - ); - - $result = $this->_db->selectExecute("multimedia_item", $params, null, null, null, array($this, "_makeItemArray")); - if ($result === false) { - $this->_db->addError(); - } - - if(!empty($result) && isset($result[0])) { - $result[0]['vote_authority'] = $this->_hasVoteAuthority($item_id); - $result[0]['comment_authority'] = $this->_hasCommentAuthority(); - return $result[0]; - } - - return $result; - } - - /** - * 編集権限を取得する - * - * @param array $insertUserID 登録者ID - * @return boolean true:権限有り、false:権限無し - * @access public - */ - function _hasEditAuthority(&$insertUserID) { - $container =& DIContainerFactory::getContainer(); - - $authID = $this->_session->getParameter("_auth_id"); - if ($authID >= _AUTH_CHIEF) { - return true; - } - - $userID = $this->_session->getParameter("_user_id"); - if ($insertUserID == $userID) { - return true; - } - - $hierarchy = $this->_session->getParameter("_hierarchy"); - $authCheck =& $container->getComponent("authCheck"); - $insetUserHierarchy = $authCheck->getPageHierarchy($insertUserID); - if ($hierarchy > $insetUserHierarchy) { - return true; - } - - return false; - } - - /** - * 投票権限を取得する - * - * @param array $item 動画データ配列 - * @return boolean true:権限有り、false:権限無し - * @access public - */ - function _hasVoteAuthority($item_id) { - $multimedia = $this->_request->getParameter("multimedia_obj"); - if ($multimedia['vote_flag'] != _ON) { - return false; - } - - $votes = $this->_session->getParameter("multimedia_votes"); - if (!empty($votes) && in_array($item_id, $votes)) { - return false; - } - - $user_id = $this->_session->getParameter("_user_id"); - if (empty($user_id)) { - return true; - } - - $params = array( - $user_id, - $item_id - ); - $sql = "SELECT vote_flag ". - "FROM {mutlimedia_user_item} ". - "WHERE user_id = ? ". - "AND item_id = ?"; - $vote_flags = $this->_db->execute($sql, $params, null, null, false); - if ($vote_flags === false) { - $this->_db->addError(); - return false; - } - - if (empty($vote_flags) || $vote_flags[0][0] != _ON) { - return true; - } - - return false; - } - - /** - * コメント権限を取得する - * - * @return boolean true:権限有り、false:権限無し - * @access public - */ - function _hasCommentAuthority() { - $multimedia = $this->_request->getParameter("multimedia_obj"); - if ($multimedia['comment_flag'] != _ON) { - return false; - } - - $auth_id = $this->_session->getParameter("_auth_id"); - if ($auth_id <= _AUTH_GUEST) { - return false; - } - - return true; - } - - /** - * 動画のコメントの計数を取得する - * - * @param string $item_id 動画id - * @return string 動画のコメントの計数 - * @access public - */ - function getCommentCount($item_id) { - $params = array( - "item_id" => intval($item_id) - ); - $commentCount = $this->_db->countExecute("multimedia_comment", $params); - - if($commentCount === false) { - $this->_db->addError(); - } - - return $commentCount; - } - - /** - * 動画のコメントを取得する - * - * @param string $item_id 動画id - * @return string 動画のコメント - * @access public - */ - function getComments($item_id, $begin=null) { - $comments = $this->_db->selectExecute("multimedia_comment", array("item_id" => intval($item_id)), array("insert_time" => "DESC"), MULTIMEDIA_VISIBLE_ITEM_COMMENT, $begin, array($this, "_makeCommentArray")); - if($comments === false) { - $this->_db->addError(); - } - - return $comments; - } - - /** - * コメントデータ配列を生成する - * - * @param array $recordSet タスクADORecordSet - * @return array タスクデータ配列 - * @access private - */ - function &_makeCommentArray(&$recordSet) { - $comments = array(); - while ($row = $recordSet->fetchRow()) { - $row["edit_authority"] = false; - if ($this->_hasEditAuthority($row["insert_user_id"])) { - $row["edit_authority"] = true; - } - - $comments[] = $row; - } - - return $comments; - } - - /** - * 画像の大きさを取得 - * - * @return string 画像の大きさ - * @access public - */ - function &getImageSize($image) { - if (is_numeric($image)) { - $container =& DIContainerFactory::getContainer(); - - $uploads =& $container->getComponent("uploadsView"); - $uploadFiles = $uploads->getUploadById($image); - if (empty($uploadFiles)) { - return false; - } - - $imageSize = getimagesize(FILEUPLOADS_DIR. "multimedia/". $uploadFiles[0]["physical_file_name"]); - } else { - $imageSize = getimagesize(HTDOCS_DIR.MULTIMEDIA_SAMPLR_JACKET_PATH.MULTIMEDIA_SAMPLR_JACKET_DIR.$image); - } - - return $imageSize; - } - - /** - * 権限判断用のSQL文FROM句を取得する - * - * @return string 権限判断用のSQL文FROM句 - * @access public - */ - function &_getAuthorityFromSQL() { - $auth_id = $this->_session->getParameter("_auth_id"); - - $sql = ""; - if ($auth_id >= _AUTH_CHIEF) { - return $sql; - } - - $sql .= "LEFT JOIN {pages_users_link} PU ". - "ON A.insert_user_id = PU.user_id ". - "AND A.room_id = PU.room_id "; - $sql .= "LEFT JOIN {authorities} AU ". - "ON PU.role_authority_id = AU.role_authority_id "; - - return $sql; - } - - /** - * 権限判断用のSQL文WHERE句を取得する - * パラメータ用配列に必要な値を追加する - * - * @param array $params パラメータ用配列 - * @return string 権限判断用のSQL文WHERE句 - * @access public - */ - function &_getAuthorityWhereSQL(&$params) { - $auth_id = $this->_session->getParameter("_auth_id"); - - $sql = ""; - if ($auth_id >= _AUTH_CHIEF) { - return $sql; - } - - $sql .= " AND (A.public_flag = ? OR AU.hierarchy < ? OR A.insert_user_id = ? "; - - $default_entry = $this->_session->getParameter("_default_entry_flag"); - $hierarchy = $this->_session->getParameter("_hierarchy"); - if ($default_entry == _ON && $hierarchy > $this->_session->getParameter("_default_entry_hierarchy")) { - $sql .= " OR AU.hierarchy IS NULL) "; - } else { - $sql .= ") "; - } - - $params[] = _ON; - $params[] = $hierarchy; - $params[] = $this->_session->getParameter("_user_id"); - - return $sql; - } - - /** - * 動画データ配列を生成する - * - * @param array $recordSet 動画ADORecordSet - * @return array 動画データ配列 - * @access private - */ - function &_makeItemArray(&$recordSet) { - $items = array(); - while ($row = $recordSet->fetchRow()) { - $row['edit_authority'] = false; - if ($this->_hasEditAuthority($row['insert_user_id'])) { - $row['edit_authority'] = true; - } - $tags = $this->getTags($row['item_id']); - $row['item_tag'] = $this->_makeTagString($tags); - $row['duration'] = floor($row['duration']/60).":".floor(($row['duration']-60*floor($row['duration']/60))); - $items[] = $row; - } - - return $items; - } - - /** - * 動画一覧共通のSQL - * - * @return array 動画件数データ - * @access public - */ - function _getItemListSQL(&$params, $where_params, $order_params=null, $count_flag=false) { - $sql = ""; - if(empty($order_params)) { - $order_params = array( - "insert_time" => "DESC" - ); - } - - if($count_flag) { - $sql = "SELECT COUNT(T.item_id) as count FROM {multimedia_item} T "; - }else { - $sql = "SELECT T.* FROM {multimedia_item} T "; - } - $sql .= "LEFT JOIN {multimedia_album} A ON T.album_id=A.album_id "; - $sql .= $this->_getAuthorityFromSQL(); - if(!empty($where_params)) { - foreach($where_params as $key => $val) { - if($val == "") { - continue; - } - $where_params["T.".$key] = $val; - unset($where_params[$key]); - } - $sql .= $this->_db->getWhereSQL($params, $where_params); - } - $sql .= $this->_getAuthorityWhereSQL($params); - if(!$count_flag) { - foreach($order_params as $key => $val) { - $order_params["T.".$key] = $val; - unset($order_params[$key]); - } - $sql .= $this->_db->getOrderSQL($order_params); - } - - return $sql; - } - - /** - * 動画一覧件数を取得する - * - * @return array 動画件数データ - * @access public - */ - function getItemListCount($where_params) { - if(empty($where_params)) { - return false; - } - - $sql = ""; - $params = array(); - $sql = $this->_getItemListSQL($params, $where_params, null, true); - $result = $this->_db->execute($sql, $params); - if ( $result === false ) { - // エラーが発生した場合、エラーリストに追加 - $this->_db->addError(); - return $result; - } - return $result[0]['count']; - } - - /** - * 動画一覧を取得する - * - * @param int $multimedia_id ID - * @return array 動画データ - * @access public - */ - function getItemList($where_params, $order_params, $begin=null) { - if(empty($where_params)) { - return false; - } - - $sql = ""; - $params = array(); - $sql = $this->_getItemListSQL($params, $where_params, $order_params); - - $result = $this->_db->execute($sql, $params ,MULTIMEDIA_VISIBLE_ITEM_CNT, $begin, true, array($this, "_makeItemArray")); - if ( $result === false ) { - // エラーが発生した場合、エラーリストに追加 - $this->_db->addError(); - return $result; - } - return $result; - } - - /** - * 検索動画一覧を取得する - * - * @return array 動画データ - * @access public - */ - function getSearchItemList($sql, $where_params, $begin=null) { - $result = $this->_db->execute($sql, $where_params ,MULTIMEDIA_SEARCH_VISIBLE_ITEM_CNT, $begin, true, array($this, "_makeItemArray")); - if ( $result === false ) { - // エラーが発生した場合、エラーリストに追加 - $this->_db->addError(); - } - return $result; - } - - /** - * タグデータ配列を取得する - * - * @return array タグデータ配列 - * @access public - */ - function getTags($item_id) { - $sql = "SELECT R.tag_value, T.used_number, R.tag_id, R.item_id, R.sequence " . - "FROM {multimedia_item_tag} AS R, {multimedia_tag} AS T " . - "WHERE R.tag_id = T.tag_id " . - "AND R.item_id = ? " . - "ORDER BY R.sequence;"; - - $params = array( - $item_id - ); - $tags = $this->_db->execute($sql, $params); - if ($tags === false) { - $this->_db->addError(); - return false; - } - return $tags; - } - - /** - * 関連動画配列を取得する - * - * @return array タグデータ配列 - * @access public - */ - function getSimilarItems($item_id) { - $tags = $this->getTags($item_id); - if(empty($tags)) { - return $tags; - } - - $params = array(); - $where_sql = ""; - foreach($tags as $tag) { - $params[] = $tag['tag_id']; - $where_sql .= " G.tag_id=? OR"; - } - $where_sql = " ( ".substr($where_sql, 0, -2)." ) "; - $sql = "SELECT T.*,count(*) as count " . - "FROM {multimedia_item_tag} AS G, {multimedia_item} AS T "; - $sql .= "LEFT JOIN {multimedia_album} A ON T.album_id=A.album_id "; - $sql .= $this->_getAuthorityFromSQL(); - $sql .= "WHERE G.item_id=T.item_id AND T.item_id <> ".$item_id." AND ".$where_sql; - $sql .= $this->_getAuthorityWhereSQL($params); - $sql .= " GROUP BY T.item_id ORDER BY count DESC"; - $items = $this->_db->execute($sql, $params, MULTIMEDIA_TAG_ITEMS_NUMBER, 0, true, array($this, "_makeItemArray")); - if ($items === false) { - $this->_db->addError(); - return false; - } - return $items; - } - - /** - * タグストリングを生成する - */ - function &_makeTagString($tags) { - $string = ""; - if(empty($tags)) { - return $string; - } - $string = ""; - foreach($tags as $tag) { - $string .= $tag['tag_value'].MULTIMEDIA_TAG_SEPARATOR; - } - $string = substr($string, 0, -1); - - return $string; - } - - /** - * ページに関する設定を行います - * - * @param int disp_cnt 1ページ当り表示件数 - * @param int now_page 現ページ - */ - function setPageInfo(&$pager, $data_cnt, $disp_cnt, $now_page = NULL){ - $pager['data_cnt'] = 0; - $pager['total_page'] = 0; - $pager['next_link'] = FALSE; - $pager['prev_link'] = FALSE; - $pager['disp_begin'] = 0; - $pager['disp_end'] = 0; - $pager['link_array'] = NULL; - - if(empty($disp_cnt)) { - return false; - } - - $pager['data_cnt'] = $data_cnt; - // now page - $pager['now_page'] = (NULL == $now_page) ? 1 : $now_page; - // total page - $pager['total_page'] = ceil($pager['data_cnt'] / $disp_cnt); - if($pager['total_page'] < $pager['now_page']) { - $pager['now_page'] = 1; - } - // link array {{ - if(($pager['now_page'] - MULTIMEDIA_FRONT_AND_BEHIND_LINK_CNT) > 0){ - $start = $pager['now_page'] - MULTIMEDIA_FRONT_AND_BEHIND_LINK_CNT; - }else{ - $start = 1; - } - if(($pager['now_page'] + MULTIMEDIA_FRONT_AND_BEHIND_LINK_CNT) >= $pager['total_page']){ - $end = $pager['total_page']; - }else{ - $end = $pager['now_page'] + MULTIMEDIA_FRONT_AND_BEHIND_LINK_CNT; - } - $i = 0; - for($i = $start; $i <= $end; $i++){ - $pager['link_array'][] = $i; - } - // next link - if($disp_cnt < $pager['data_cnt']){ - if($pager['now_page'] < $pager['total_page']){ - $pager['next_link'] = TRUE; - } - } - // prev link - if(1 < $pager['now_page']){ - $pager['prev_link'] = TRUE; - } - // begin disp number - $pager['disp_begin'] = ($pager['now_page'] - 1) * $disp_cnt; - // end disp number - $tmp_cnt = $pager['now_page'] * $disp_cnt; - $pager['disp_end'] = ($pager['data_cnt'] < $tmp_cnt) ? $pager['data_cnt'] : $tmp_cnt; - } -} +_db =& $container->getComponent("DbObject"); + $this->_request =& $container->getComponent("Request"); + $this->_session =& $container->getComponent("Session"); + } + + /** + * 配置されている動画配信IDを取得する + * + * @return string 配置されている動画配信ID + * @access public + */ + function &getCurrentMultimediaId() { + $params = array($this->_request->getParameter("block_id")); + $sql = "SELECT multimedia_id ". + "FROM {multimedia_block} ". + "WHERE block_id = ?"; + $result = $this->_db->execute($sql, $params); + if ($result === false) { + $this->_db->addError(); + return $result; + } + + return $result[0]["multimedia_id"]; + } + + /** + * 現在登録されている動画配信IDを取得する + * + * @return string 配置されている動画配信ID + * @access pblic + */ + function &getFirstMultimediaId() { + $params = array( + $this->_request->getParameter('room_id') + ); + $sql = "SELECT multimedia_id " + . "FROM {multimedia} " + . "WHERE room_id = ?"; + $result = $this->_db->execute($sql, $params, 1); + if ($result === false) { + $this->_db->addError(); + return $result; + } + + return $result[0]['multimedia_id']; + } + + /** + * 動画配信が配置されているブロックデータを取得する + * + * @return string ブロックデータ + * @access public + */ + function &getBlock() { + $params = array($this->_request->getParameter("multimedia_id")); + $sql = "SELECT M.room_id, B.block_id ". + "FROM {multimedia} M ". + "INNER JOIN {multimedia_block} B ". + "ON M.multimedia_id = B.multimedia_id ". + "WHERE M.multimedia_id = ? ". + "ORDER BY B.block_id"; + $result = $this->_db->execute($sql, $params, 1); + if ($result === false) { + $this->_db->addError(); + return $result; + } + + return $result[0]; + } + + /** + * 動画配信が存在するか判断する + * + * @return boolean true:存在する、false:存在しない + * @access public + */ + function multimediaExist() { + $params = array( + $this->_request->getParameter("multimedia_id"), + $this->_request->getParameter("room_id") + ); + $sql = "SELECT multimedia_id ". + "FROM {multimedia} ". + "WHERE multimedia_id = ? ". + "AND room_id = ?"; + $result = $this->_db->execute($sql, $params); + if ($result === false) { + $this->_db->addError(); + return $result; + } + + if (count($result) > 0) { + return true; + } + + return false; + } + + function getMultimediaCount() { + $params["room_id"] = $this->_request->getParameter("room_id"); + $count = $this->_db->countExecute("multimedia", $params); + if($count === false) { + $this->_db->addError(); + } + + return $count; + } + + /** + * 動画配信の設定データを取得する + * + * @return string 設定データ配列 + * @access public + */ + function &getConfig() { + $container =& DIContainerFactory::getContainer(); + $configView =& $container->getComponent("configView"); + $module_id = $this->_request->getParameter("module_id"); + $config = $configView->getConfig($module_id, false); + + return $config; + } + + /** + * 動画配信用デフォルトデータを取得する + * + * @return array 動画配信用デフォルトデータ配列 + * @access public + */ + function &getDefaultMultimedia() { + $config = $this->getConfig(); + if ($config === false) { + return $config; + } + + $multimedia = array( + "album_authority" => constant($config['album_authority']['conf_value']), + "vote_flag" => constant($config['vote_flag']['conf_value']), + "comment_flag" => constant($config['comment_flag']['conf_value']), + "confirm_flag" => constant($config['confirm_flag']['conf_value']), + "display" => constant($config['display']['conf_value']), + "autoplay_flag" => constant($config['autoplay_flag']['conf_value']), + "buffer_time" => $config['buffer_time']['conf_value'], + "album_visible_row" => $config['album_visible_row']['conf_value'], + "new_period" => $config['new_period']['conf_value'], + "album_jacket" => $config['album_jacket']['conf_value'] + ); + + return $multimedia; + } + + /** + * 動画配信データを取得する + * + * @return array 動画配信データ + * @access public + */ + function &getCurrentMultimedia() { + $params = array($this->_request->getParameter("block_id")); + $sql = "SELECT B.block_id, B.multimedia_id, B.display, ". + "B.autoplay_flag, B.buffer_time, ". + "B.album_visible_row, B.new_period, ". + "M.album_authority, M.vote_flag, M.comment_flag, M.confirm_flag ". + "FROM {multimedia_block} B ". + "INNER JOIN {multimedia} M ". + "ON B.multimedia_id = M.multimedia_id ". + "WHERE block_id = ?"; + $result = $this->_db->execute($sql, $params); + if ($result === false) { + $this->_db->addError(); + } + if (empty($result)) { + return $result; + } + + $result[0]['album_authority'] = $this->_hasAlbumAuthority($result[0]); + $result[0]['new_period_time'] = $this->_getNewPeriodTime($result[0]['new_period']); + + return $result[0]; + } + + /** + * アルバム作成権限を取得する + * + * @param array $photoalbum フォトアルバムデータ配列 + * @return boolean true:権限有り、false:権限無し + * @access public + */ + function _hasAlbumAuthority($multimedia) { + $auth_id = $this->_session->getParameter("_auth_id"); + if ($auth_id >= $multimedia['album_authority']) { + return true; + } + + return false; + } + + function getMultimediaById($multimedia_id) { + $params = array( + "multimedia_id" => $multimedia_id + ); + + $result = $this->_db->selectExecute("multimedia", $params); + if ($result === false) { + $this->_db->addError(); + } + + if(!empty($result) && isset($result[0])) { + return $result[0]; + } + + return $result; + } + + /** + * フォトアルバムデータを取得する + * + * @return array フォトアルバムデータ + * @access public + */ + function &getMultimedia() { + $params = array($this->_request->getParameter("multimedia_id")); + $sql = "SELECT multimedia_id, album_authority, vote_flag, comment_flag, confirm_flag ". + "FROM {multimedia} ". + "WHERE multimedia_id = ?"; + $result = $this->_db->execute($sql, $params); + if ($result === false) { + $this->_db->addError(); + return $result; + } + + return $result[0]; + } + + /** + * new記号表示期間から対象年月日を取得する + * + * @param string $new_period new記号表示期間 + * @return string new記号表示対象年月日(YmdHis) + * @access public + */ + function &_getNewPeriodTime($new_period) { + if (empty($new_period)) { + $new_period = -1; + } + + $time = timezone_date(); + $time = mktime(0, 0, 0, + intval(substr($time, 4, 2)), + intval(substr($time, 6, 2)) - $new_period, + intval(substr($time, 0, 4)) + ); + $time = date("YmdHis", $time); + + return $time; + } + + /** + * 動画配信のアルバムの計数を取得する + * + * @param string $new_period new記号表示期間 + * @return string new記号表示対象年月日(YmdHis) + * @access public + */ + function getAlbumCount($multimedia_id) { + $params[] = $multimedia_id; + + $sql = "SELECT COUNT(*) as count ". + "FROM {multimedia_album} A "; + $sql .= $this->_getAuthorityFromSQL(); + $sql .= "WHERE A.multimedia_id = ? "; + $sql .= $this->_getAuthorityWhereSQL($params); + if(!empty($order_params)) { + $sql .= $this->_db->getOrderSQL($order_params); + } + $result = $this->_db->execute($sql, $params); + if ( $result === false ) { + // エラーが発生した場合、エラーリストに追加 + $this->_db->addError(); + return $result; + } + return $result[0]['count']; + } + + /** + * アルバム一覧を取得する + * + * @return array アルバム一覧データ + * @access public + */ + function getAlbumList($multimedia_id, $order_params=null, $disp_cnt=null, $begin=null) { + $params[] = $multimedia_id; + + $sql = "SELECT A.* ". + "FROM {multimedia_album} A "; + $sql .= $this->_getAuthorityFromSQL(); + $sql .= "WHERE A.multimedia_id = ? "; + $sql .= $this->_getAuthorityWhereSQL($params); + if(!empty($order_params)) { + $sql .= $this->_db->getOrderSQL($order_params); + } + $result = $this->_db->execute($sql, $params, $disp_cnt, $begin, true, array($this, "_makeAlbumArray")); + if ( $result === false ) { + // エラーが発生した場合、エラーリストに追加 + $this->_db->addError(); + } + + return $result; + } + + /** + * アルバムデータ配列を生成する + * + * @param array $recordSet タスクADORecordSet + * @return array タスクデータ配列 + * @access private + */ + function &_makeAlbumArray(&$recordSet) { + $multimedia = $this->_request->getParameter("multimedia_obj"); + + $albums = array(); + while ($row = $recordSet->fetchRow()) { + if (!empty($row["album_jacket"])) { + $row["jacket_style"] = $this->getImageStyle($row["width"], $row["height"], MULTIMEDIA_JACKET_WIDTH, MULTIMEDIA_JACKET_HEIGHT); + } + + $row["edit_authority"] = false; + if ($multimedia["album_authority"] + && $this->_hasEditAuthority($row["insert_user_id"])) { + $row["edit_authority"] = true; + } + + $albums[] = $row; + } + + return $albums; + } + + /** + * アルバムのサムネイルのスタイル属性値を取得する + * + * @param string $width 幅 + * @param string $height 高さ + * @param string $maxWidth 最大幅 + * @param string $maxHeight 最大高さ + * @return array 画像のスタイル属性値 + * @access private + */ + function &getImageStyle($width, $height, $maxWidth, $maxHeight) { + $ratio = $height / $width; + + $widthRatio = $width / $maxWidth; + $heightRatio = $height / $maxHeight; + + if ($widthRatio > $heightRatio) { + $height = $maxHeight; + $widht = intval($height / $ratio); + $top = 0; + $right = intval(($widht + $maxWidth) / 2); + $bottom = $maxHeight; + $left = intval(($widht - $maxWidth) / 2); + $marginLeft = $left * -1; + $marginTop = $top; + } else { + $widht = $maxWidth; + $height = intval($widht * $ratio); + $top = intval(($height - $maxHeight) / 2); + $right = $maxWidth; + $bottom = intval(($height + $maxHeight) / 2); + $left = 0; + $marginLeft = $left; + $marginTop = $top * -1; + } + + $style = sprintf(MULTIMEDIA_THUMBNAIL_STYLE, $widht, $height, $top, $right, $bottom, $left, $marginLeft, $marginTop); + + return $style; + } + + /** + * アルバムを取得する + * + * @return array アルバムデータ + * @access public + */ + function getAlbum($album_id) { + $params = array( + "album_id" => intval($album_id) + ); + + $result = $this->_db->selectExecute("multimedia_album", $params, null, null, null, array($this, "_makeAlbumArray")); + if ($result === false) { + $this->_db->addError(); + } + + if(!empty($result) && isset($result[0])) { + return $result[0]; + } + + return $result; + } + + /** + * 動画を取得する + * + * @return array 動画データ + * @access public + */ + function getItem($item_id) { + $params = array( + "item_id" => intval($item_id) + ); + + $result = $this->_db->selectExecute("multimedia_item", $params, null, null, null, array($this, "_makeItemArray")); + if ($result === false) { + $this->_db->addError(); + } + + if(!empty($result) && isset($result[0])) { + $result[0]['vote_authority'] = $this->_hasVoteAuthority($item_id); + $result[0]['comment_authority'] = $this->_hasCommentAuthority(); + return $result[0]; + } + + return $result; + } + + /** + * 編集権限を取得する + * + * @param array $insertUserID 登録者ID + * @return boolean true:権限有り、false:権限無し + * @access public + */ + function _hasEditAuthority(&$insertUserID) { + $container =& DIContainerFactory::getContainer(); + + $authID = $this->_session->getParameter("_auth_id"); + if ($authID >= _AUTH_CHIEF) { + return true; + } + + $userID = $this->_session->getParameter("_user_id"); + if ($insertUserID == $userID) { + return true; + } + + $hierarchy = $this->_session->getParameter("_hierarchy"); + $authCheck =& $container->getComponent("authCheck"); + $insetUserHierarchy = $authCheck->getPageHierarchy($insertUserID); + if ($hierarchy > $insetUserHierarchy) { + return true; + } + + return false; + } + + /** + * 投票権限を取得する + * + * @param array $item 動画データ配列 + * @return boolean true:権限有り、false:権限無し + * @access public + */ + function _hasVoteAuthority($item_id) { + $multimedia = $this->_request->getParameter("multimedia_obj"); + if ($multimedia['vote_flag'] != _ON) { + return false; + } + + $votes = $this->_session->getParameter("multimedia_votes"); + if (!empty($votes) && in_array($item_id, $votes)) { + return false; + } + + $user_id = $this->_session->getParameter("_user_id"); + if (empty($user_id)) { + return true; + } + + $params = array( + $user_id, + $item_id + ); + $sql = "SELECT vote_flag ". + "FROM {mutlimedia_user_item} ". + "WHERE user_id = ? ". + "AND item_id = ?"; + $vote_flags = $this->_db->execute($sql, $params, null, null, false); + if ($vote_flags === false) { + $this->_db->addError(); + return false; + } + + if (empty($vote_flags) || $vote_flags[0][0] != _ON) { + return true; + } + + return false; + } + + /** + * コメント権限を取得する + * + * @return boolean true:権限有り、false:権限無し + * @access public + */ + function _hasCommentAuthority() { + $multimedia = $this->_request->getParameter("multimedia_obj"); + if ($multimedia['comment_flag'] != _ON) { + return false; + } + + $auth_id = $this->_session->getParameter("_auth_id"); + if ($auth_id <= _AUTH_GUEST) { + return false; + } + + return true; + } + + /** + * 動画のコメントの計数を取得する + * + * @param string $item_id 動画id + * @return string 動画のコメントの計数 + * @access public + */ + function getCommentCount($item_id) { + $params = array( + "item_id" => intval($item_id) + ); + $commentCount = $this->_db->countExecute("multimedia_comment", $params); + + if($commentCount === false) { + $this->_db->addError(); + } + + return $commentCount; + } + + /** + * 動画のコメントを取得する + * + * @param string $item_id 動画id + * @return string 動画のコメント + * @access public + */ + function getComments($item_id, $begin=null) { + $comments = $this->_db->selectExecute("multimedia_comment", array("item_id" => intval($item_id)), array("insert_time" => "DESC"), MULTIMEDIA_VISIBLE_ITEM_COMMENT, $begin, array($this, "_makeCommentArray")); + if($comments === false) { + $this->_db->addError(); + } + + return $comments; + } + + /** + * コメントデータ配列を生成する + * + * @param array $recordSet タスクADORecordSet + * @return array タスクデータ配列 + * @access private + */ + function &_makeCommentArray(&$recordSet) { + $comments = array(); + while ($row = $recordSet->fetchRow()) { + $row["edit_authority"] = false; + if ($this->_hasEditAuthority($row["insert_user_id"])) { + $row["edit_authority"] = true; + } + + $comments[] = $row; + } + + return $comments; + } + + /** + * 画像の大きさを取得 + * + * @return string 画像の大きさ + * @access public + */ + function &getImageSize($image) { + if (is_numeric($image)) { + $container =& DIContainerFactory::getContainer(); + + $uploads =& $container->getComponent("uploadsView"); + $uploadFiles = $uploads->getUploadById($image); + if (empty($uploadFiles)) { + return false; + } + + $imageSize = getimagesize(FILEUPLOADS_DIR. "multimedia/". $uploadFiles[0]["physical_file_name"]); + } else { + $imageSize = getimagesize(HTDOCS_DIR.MULTIMEDIA_SAMPLR_JACKET_PATH.MULTIMEDIA_SAMPLR_JACKET_DIR.$image); + } + + return $imageSize; + } + + /** + * 権限判断用のSQL文FROM句を取得する + * + * @return string 権限判断用のSQL文FROM句 + * @access public + */ + function &_getAuthorityFromSQL() { + $auth_id = $this->_session->getParameter("_auth_id"); + + $sql = ""; + if ($auth_id >= _AUTH_CHIEF) { + return $sql; + } + + $sql .= "LEFT JOIN {pages_users_link} PU ". + "ON A.insert_user_id = PU.user_id ". + "AND A.room_id = PU.room_id "; + $sql .= "LEFT JOIN {authorities} AU ". + "ON PU.role_authority_id = AU.role_authority_id "; + + return $sql; + } + + /** + * 権限判断用のSQL文WHERE句を取得する + * パラメータ用配列に必要な値を追加する + * + * @param array $params パラメータ用配列 + * @return string 権限判断用のSQL文WHERE句 + * @access public + */ + function &_getAuthorityWhereSQL(&$params) { + $auth_id = $this->_session->getParameter("_auth_id"); + + $sql = ""; + if ($auth_id >= _AUTH_CHIEF) { + return $sql; + } + + $sql .= " AND (A.public_flag = ? OR AU.hierarchy < ? OR A.insert_user_id = ? "; + + $default_entry = $this->_session->getParameter("_default_entry_flag"); + $hierarchy = $this->_session->getParameter("_hierarchy"); + if ($default_entry == _ON && $hierarchy > $this->_session->getParameter("_default_entry_hierarchy")) { + $sql .= " OR AU.hierarchy IS NULL) "; + } else { + $sql .= ") "; + } + + $params[] = _ON; + $params[] = $hierarchy; + $params[] = $this->_session->getParameter("_user_id"); + + return $sql; + } + + /** + * 動画データ配列を生成する + * + * @param array $recordSet 動画ADORecordSet + * @return array 動画データ配列 + * @access private + */ + function &_makeItemArray(&$recordSet) { + $items = array(); + while ($row = $recordSet->fetchRow()) { + $row['edit_authority'] = false; + if ($this->_hasEditAuthority($row['insert_user_id'])) { + $row['edit_authority'] = true; + } + $tags = $this->getTags($row['item_id']); + $row['item_tag'] = $this->_makeTagString($tags); + $row['duration'] = floor($row['duration']/60).":".floor(($row['duration']-60*floor($row['duration']/60))); + $items[] = $row; + } + + return $items; + } + + /** + * 動画一覧共通のSQL + * + * @return array 動画件数データ + * @access public + */ + function _getItemListSQL(&$params, $where_params, $order_params=null, $count_flag=false) { + $sql = ""; + if(empty($order_params)) { + $order_params = array( + "insert_time" => "DESC" + ); + } + + if($count_flag) { + $sql = "SELECT COUNT(T.item_id) as count FROM {multimedia_item} T "; + }else { + $sql = "SELECT T.* FROM {multimedia_item} T "; + } + $sql .= "LEFT JOIN {multimedia_album} A ON T.album_id=A.album_id "; + $sql .= $this->_getAuthorityFromSQL(); + if(!empty($where_params)) { + foreach($where_params as $key => $val) { + if($val == "") { + continue; + } + $where_params["T.".$key] = $val; + unset($where_params[$key]); + } + $sql .= $this->_db->getWhereSQL($params, $where_params); + } + $sql .= $this->_getAuthorityWhereSQL($params); + if(!$count_flag) { + foreach($order_params as $key => $val) { + $order_params["T.".$key] = $val; + unset($order_params[$key]); + } + $sql .= $this->_db->getOrderSQL($order_params); + } + + return $sql; + } + + /** + * 動画一覧件数を取得する + * + * @return array 動画件数データ + * @access public + */ + function getItemListCount($where_params) { + if(empty($where_params)) { + return false; + } + + $sql = ""; + $params = array(); + $sql = $this->_getItemListSQL($params, $where_params, null, true); + $result = $this->_db->execute($sql, $params); + if ( $result === false ) { + // エラーが発生した場合、エラーリストに追加 + $this->_db->addError(); + return $result; + } + return $result[0]['count']; + } + + /** + * 動画一覧を取得する + * + * @param int $multimedia_id ID + * @return array 動画データ + * @access public + */ + function getItemList($where_params, $order_params, $begin=null) { + if(empty($where_params)) { + return false; + } + + $sql = ""; + $params = array(); + $sql = $this->_getItemListSQL($params, $where_params, $order_params); + + $result = $this->_db->execute($sql, $params ,MULTIMEDIA_VISIBLE_ITEM_CNT, $begin, true, array($this, "_makeItemArray")); + if ( $result === false ) { + // エラーが発生した場合、エラーリストに追加 + $this->_db->addError(); + return $result; + } + return $result; + } + + /** + * 検索動画一覧を取得する + * + * @return array 動画データ + * @access public + */ + function getSearchItemList($sql, $where_params, $begin=null) { + $result = $this->_db->execute($sql, $where_params ,MULTIMEDIA_SEARCH_VISIBLE_ITEM_CNT, $begin, true, array($this, "_makeItemArray")); + if ( $result === false ) { + // エラーが発生した場合、エラーリストに追加 + $this->_db->addError(); + } + return $result; + } + + /** + * タグデータ配列を取得する + * + * @return array タグデータ配列 + * @access public + */ + function getTags($item_id) { + $sql = "SELECT R.tag_value, T.used_number, R.tag_id, R.item_id, R.sequence " . + "FROM {multimedia_item_tag} AS R, {multimedia_tag} AS T " . + "WHERE R.tag_id = T.tag_id " . + "AND R.item_id = ? " . + "ORDER BY R.sequence;"; + + $params = array( + $item_id + ); + $tags = $this->_db->execute($sql, $params); + if ($tags === false) { + $this->_db->addError(); + return false; + } + return $tags; + } + + /** + * 関連動画配列を取得する + * + * @return array タグデータ配列 + * @access public + */ + function getSimilarItems($item_id) { + $tags = $this->getTags($item_id); + if(empty($tags)) { + return $tags; + } + + $params = array(); + $where_sql = ""; + foreach($tags as $tag) { + $params[] = $tag['tag_id']; + $where_sql .= " G.tag_id=? OR"; + } + $where_sql = " ( ".substr($where_sql, 0, -2)." ) "; + $sql = "SELECT T.*,count(*) as count " . + "FROM {multimedia_item_tag} AS G, {multimedia_item} AS T "; + $sql .= "LEFT JOIN {multimedia_album} A ON T.album_id=A.album_id "; + $sql .= $this->_getAuthorityFromSQL(); + $sql .= "WHERE G.item_id=T.item_id AND T.item_id <> ".$item_id." AND ".$where_sql; + $sql .= $this->_getAuthorityWhereSQL($params); + $sql .= " GROUP BY T.item_id ORDER BY count DESC"; + $items = $this->_db->execute($sql, $params, MULTIMEDIA_TAG_ITEMS_NUMBER, 0, true, array($this, "_makeItemArray")); + if ($items === false) { + $this->_db->addError(); + return false; + } + return $items; + } + + /** + * タグストリングを生成する + */ + function &_makeTagString($tags) { + $string = ""; + if(empty($tags)) { + return $string; + } + $string = ""; + foreach($tags as $tag) { + $string .= $tag['tag_value'].MULTIMEDIA_TAG_SEPARATOR; + } + $string = substr($string, 0, -1); + + return $string; + } + + /** + * ページに関する設定を行います + * + * @param int disp_cnt 1ページ当り表示件数 + * @param int now_page 現ページ + */ + function setPageInfo(&$pager, $data_cnt, $disp_cnt, $now_page = NULL){ + $pager['data_cnt'] = 0; + $pager['total_page'] = 0; + $pager['next_link'] = FALSE; + $pager['prev_link'] = FALSE; + $pager['disp_begin'] = 0; + $pager['disp_end'] = 0; + $pager['link_array'] = NULL; + + if(empty($disp_cnt)) { + return false; + } + + $pager['data_cnt'] = $data_cnt; + // now page + $pager['now_page'] = (NULL == $now_page) ? 1 : $now_page; + // total page + $pager['total_page'] = ceil($pager['data_cnt'] / $disp_cnt); + if($pager['total_page'] < $pager['now_page']) { + $pager['now_page'] = 1; + } + // link array {{ + if(($pager['now_page'] - MULTIMEDIA_FRONT_AND_BEHIND_LINK_CNT) > 0){ + $start = $pager['now_page'] - MULTIMEDIA_FRONT_AND_BEHIND_LINK_CNT; + }else{ + $start = 1; + } + if(($pager['now_page'] + MULTIMEDIA_FRONT_AND_BEHIND_LINK_CNT) >= $pager['total_page']){ + $end = $pager['total_page']; + }else{ + $end = $pager['now_page'] + MULTIMEDIA_FRONT_AND_BEHIND_LINK_CNT; + } + $i = 0; + for($i = $start; $i <= $end; $i++){ + $pager['link_array'][] = $i; + } + // next link + if($disp_cnt < $pager['data_cnt']){ + if($pager['now_page'] < $pager['total_page']){ + $pager['next_link'] = TRUE; + } + } + // prev link + if(1 < $pager['now_page']){ + $pager['prev_link'] = TRUE; + } + // begin disp number + $pager['disp_begin'] = ($pager['now_page'] - 1) * $disp_cnt; + // end disp number + $tmp_cnt = $pager['now_page'] * $disp_cnt; + $pager['disp_end'] = ($pager['data_cnt'] < $tmp_cnt) ? $pager['data_cnt'] : $tmp_cnt; + } +} ?> \ No newline at end of file diff --git a/multimedia/config/main.ini b/multimedia/config/main.ini index 6b4517e..65e8da9 100644 --- a/multimedia/config/main.ini +++ b/multimedia/config/main.ini @@ -16,6 +16,7 @@ define:MULTIMEDIA_EXTENSION = "ffmpeg" define:MULTIMEDIA_MOVIE_THUMBNAIL_WIDTH = 120 define:MULTIMEDIA_MOVIE_THUMBNAIL_HEIGHT = 90 define:MULTIMEDIA_MOVIE_THUMBNAIL_NAME = "_thumbnail.jpg" +define:MULTIMEDIA_MOVIE_CAPTUER_NAME = "_temp.jpg" define:MULTIMEDIA_MOVIE_THUMBNAIL_ROW_NUMBER = 4 define:MULTIMEDIA_MOVIE_TYPE_NEW = "new" define:MULTIMEDIA_MOVIE_TYPE_POP = "pop" @@ -37,7 +38,14 @@ define:MULTIMEDIA_TAG_SEPARATOR = "," define:MULTIMEDIA_TAG_ITEMS_NUMBER = 6 define:MULTIMEDIA_MOVIE_PLAYER_WIDTH = 504 define:MULTIMEDIA_MOVIE_PLAYER_HEIGHT = 290 +define:MULTIMEDIA_MOVIE_PLAYER_CONTROLLER_HEIGHT = 24 ;sv +define:MULTIMEDIA_MOVIE_PLAYER_EMBEDED_WIDTH = 400 +define:MULTIMEDIA_MOVIE_PLAYER_EMBEDED_HEIGHT = 300 define:MULTIMEDIA_GET_FLASH_LINK = "http://www.adobe.com/go/getflashplayer" define:MULTIMEDIA_GET_FLASH_ICON = "http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" define:MULTIMEDIA_VISIBLE_ITEM_COMMENT = 5 -define:MULTIMEDIA_SEARCH_VISIBLE_ITEM_CNT = 5 \ No newline at end of file +define:MULTIMEDIA_SEARCH_VISIBLE_ITEM_CNT = 5 +define:MULTIMEDIA_FFMPEG_PATH = "/usr/bin/ffmpeg" +define:MULTIMEDIA_FFMPEG_OPTION = "-acodec libfaac -ar 44100 -vcodec libx264 -vpre medium -r 30 -b 500k" +define:MULTIMEDIA_MP4BOX_PATH = "/usr/local/bin/MP4Box" +define:MULTIMEDIA_THUMBNAIL_SECONDS = 10 diff --git a/multimedia/files/css/default/style.css b/multimedia/files/css/default/style.css index 2e7a62e..bd2b71c 100644 --- a/multimedia/files/css/default/style.css +++ b/multimedia/files/css/default/style.css @@ -589,4 +589,537 @@ div.multimedia_search_title { } .multimedia_upload_table_td{ width:260px; -} \ No newline at end of file +} +.multimedia_player_background{ + border:1px solid #bbb; +} +.multimedia_player_thumbnail{ + width:100%; + height:100%; +} +.multimedia_player_error_block{ + position:absolute; + margin-top:-27px; + height:26px; + background-color:#000; + border-top:1px solid #bbb; +} +.multimedia_player_error_detail{ + margin:5px; + font-size:13px; + color:#fff; +} + +/* 以下、動画プレイヤー用 */ +div.jp-video { + font-size:1.25em; /* 1.25em for testing in site pages */ /* No parent CSS that can effect the size in the demos ZIP */ + font-family:Verdana, Arial, sans-serif; + line-height:1.6; + color: #000; + background-color:#eee; +} + +div.jp-video-embeded { + width:400px; /* 幅を変更する場合はここを修正 */ +} +div.jp-video-normal { + width:504px; /* 幅を変更する場合はここを修正 */ +} +div.jp-video-full { + position:static !important; position:relative +} + +div.jp-video-full div div { + z-index:1000; +} + +div.jp-video-full div.jp-jplayer { + top: 0; + left: 0; + position: fixed !important; position: relative; + overflow: hidden; +} + +div.jp-video-full div.jp-gui { + position: fixed !important; position: static; + top: 0; + left: 0; + width:100%; + height:100%; + z-index:1001; +} + +div.jp-video-full div.jp-interface { + position: absolute !important; position: relative; + bottom: 0; + left: 0; +} + +div.jp-gui div.jp-interface { + position: relative; + background-color:#eee; + width:100%; + margin-top: -21px; +} + +div.jp-video div.jp-interface { +} + +/* @group CONTROLS */ + +div.jp-controls-holder { + clear: both; + margin:0 auto; + position: relative; + overflow:hidden; + height:18px; + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") 0 -101px repeat-x; + border-left: 1px solid #bbb; + border-right: 1px solid #bbb; +} + +div.jp-interface ul.jp-controls { + list-style-type:none; + margin:0; + padding: 0; + overflow:hidden; +} + +div.jp-interface ul.jp-controls-left { + list-style-type:none; + margin:0; + padding: 0; + overflow:hidden; + margin-top: 1px; +} + +div.jp-interface ul.jp-controls-right { + list-style-type:none; + margin:0; + padding: 0; + overflow:hidden; + margin-top: 1px; +} + +div.jp-video div.jp-type-single ul.jp-controls { + width: 78px; + margin-left: 200px; +} + +div.jp-video div.jp-type-single ul.jp-controls-left { +} + +div.jp-video div.jp-type-single ul.jp-controls-right { +} + +div.jp-video ul.jp-controls, +div.jp-interface ul.jp-controls li { + display:inline; + float: left; +} + +div.jp-video ul.jp-controls-left, +div.jp-interface ul.jp-controls-left li { + display:inline; + float: left; +} + +div.jp-video ul.jp-controls-right, +div.jp-interface ul.jp-controls-right li { + display:inline; + float: right; +} + +div.jp-interface ul.jp-controls a { + display:block; + overflow:hidden; + text-indent:-9999px; +} + +div.jp-interface ul.jp-controls-left a { + display:block; + overflow:hidden; + text-indent:-9999px; +} + +div.jp-interface ul.jp-controls-right a { + display:block; + overflow:hidden; + text-indent:-9999px; +} + +a.jp-play, +a.jp-pause { + width: 15px; + height: 15px; +} + +a.jp-play { + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") 0 0 no-repeat; + margin-left: 6px; +} +a.jp-play:hover { + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") -17px 0 no-repeat; +} +a.jp-pause { + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") 0 -16px no-repeat; + margin-left: 6px; + display: none; +} +a.jp-pause:hover { + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") -17px -16px no-repeat; +} + +a.jp-stop { + display: none; +} + +/* @group progress bar */ + +div.jp-progress { + overflow:hidden; + background-color: #ddd; +} + +div.jp-video div.jp-progress { + top:0px; + left:0px; + width:100%; + height:3px; +} +div.jp-seek-bar { + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") 0 -81px repeat-x; + width:0px; + height:100%; + cursor: pointer; +} +div.jp-play-bar { + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") 0 -85px repeat-x ; + width:0px; + height:100%; +} + +div.jp-seeking-bg { + background: url("jplayer/jplayer.blue.monday.seeking.gif"); +} + +/* @group volume controls */ + +a.jp-mute, +a.jp-unmute, +a.jp-volume-max { + width:16px; + height:15px; + margin-left: 3px; +} + +div.jp-video a.jp-mute, +div.jp-video a.jp-unmute, +div.jp-video a.jp-volume-max { +} + +div.jp-video a.jp-mute, +div.jp-video a.jp-unmute { + left: 50px; +} + +div.jp-video a.jp-volume-max { + left: 134px; +} + +a.jp-mute { + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") 0 -48px no-repeat; +} +a.jp-mute:hover { + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") -17px -48px no-repeat; +} +a.jp-unmute { + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") 0 -32px no-repeat; + display: none; +} +a.jp-unmute:hover { + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") -17px -32px no-repeat; +} + +a.jp-volume-max { + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") 0 -32px no-repeat; +} +a.jp-volume-max:hover { + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") -17px -32px no-repeat; +} + +div.jp-volume-bar { + overflow:hidden; + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") 0 -89px repeat-x; + width:100px; + height:5px; + cursor: pointer; + margin-top: 5px; + margin-left:3px; +} + +div.jp-video div.jp-volume-bar { +} +div.jp-volume-bar-value { + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") 0 -95px repeat-x; + width:0px; + height:5px; +} + +/* @group current time and duration */ + +div.jp-audio div.jp-time-holder { + position:absolute; + top:50px; +} +div.jp-audio div.jp-type-single div.jp-time-holder { + left:110px; + width:186px; +} +div.jp-audio div.jp-type-playlist div.jp-time-holder { + left:166px; + width:130px; +} + +div.jp-current-time, +div.jp-duration { + font-size: 9px; +} +div.jp-current-time { +} +div.jp-duration { +} + +div.jp-video div.jp-current-time { + margin-left: 5px; +} +div.jp-video div.jp-duration { + margin-left: 5px; +} + +/* @group playlist */ + +div.jp-title { + font-weight:bold; + text-align:center; +} + +div.jp-title, +div.jp-playlist { + width:100%; + background-color:#ccc; + border-top:1px solid #009be3; +} +div.jp-type-single div.jp-title, +div.jp-type-playlist div.jp-title, +div.jp-type-single div.jp-playlist { + border-top:none; +} +div.jp-title ul, +div.jp-playlist ul { + list-style-type:none; + margin:0; + padding:0 20px; + font-size:.72em; +} + +div.jp-title li { + padding:5px 0; + font-weight:bold; +} +div.jp-playlist li { + padding:5px 0 4px 20px; + border-bottom:1px solid #eee; +} + +div.jp-playlist li div { + display:inline; +} + +div.jp-type-playlist div.jp-playlist li:last-child { + padding:5px 0 5px 20px; + border-bottom:none; +} +div.jp-type-playlist div.jp-playlist li.jp-playlist-current { + list-style-type:square; + list-style-position:inside; + padding-left:7px; +} +div.jp-type-playlist div.jp-playlist a { + color: #333; + text-decoration: none; +} +div.jp-type-playlist div.jp-playlist a:hover { + color:#0d88c1; +} +div.jp-type-playlist div.jp-playlist a.jp-playlist-current { + color:#0d88c1; +} + +div.jp-type-playlist div.jp-playlist a.jp-playlist-item-remove { + float:right; + display:inline; + text-align:right; + margin-right:10px; + font-weight:bold; + color:#666; +} +div.jp-type-playlist div.jp-playlist a.jp-playlist-item-remove:hover { + color:#0d88c1; +} +div.jp-type-playlist div.jp-playlist span.jp-free-media { + float:right; + display:inline; + text-align:right; + margin-right:10px; +} +div.jp-type-playlist div.jp-playlist span.jp-free-media a{ + color:#666; +} +div.jp-type-playlist div.jp-playlist span.jp-free-media a:hover{ + color:#0d88c1; +} +span.jp-artist { + font-size:.8em; + color:#666; +} + +/* @end */ + +div.jp-video-play { + width:100%; + overflow:hidden; + cursor:pointer; + background-color:rgba(0,0,0,0); +} +div.jp-video-embeded div.jp-video-play { + /* 高さを変更する場合はここを修正 */ + margin-top:-300px; + height:300px; +} +div.jp-video-normal div.jp-video-play { + /* 高さを変更する場合はここを修正 */ + margin-top:-290px; + height:290px; +} +div.jp-video-full div.jp-video-play { + height:100%; +} +a.jp-video-play-icon { + position:relative; + display:block; + width: 80px; + height: 80px; + margin-left:-40px; + margin-top:-40px; + left:50%; + top:50%; + background: url("jplayer/jplayer.netcommons.video.play.png") 0 0 no-repeat; + text-indent:-9999px; +} + +div.jp-video-full a.jp-video-play-icon { + position:absolute; + z-index:1002; +} + +div.jp-jplayer { + width:0px; + height:0px; +} + +div.jp-jplayer { + background-color: #000000; + border:1px solid #bbb; +} + +/* @group TOGGLES */ + +ul.jp-toggles { + list-style-type:none; + padding:0; + margin:0 auto; + overflow:hidden; +} + +div.jp-video ul.jp-toggles { + margin-top:10px; + width:100px; +} + +ul.jp-toggles li { + display:block; + float:right; +} + +ul.jp-toggles li a { + display:block; + width:25px; + height:18px; + text-indent:-9999px; + line-height:100%; +} + +a.jp-full-screen { + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") 0 -64px no-repeat; + width: 16px; + height: 15px; + margin-left: 5px; + margin-right: 5px; +} + +a.jp-full-screen:hover { + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") -17px -64px no-repeat; +} + +a.jp-restore-screen { + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") 0 -64px no-repeat; + width: 16px; + height: 15px; + margin-left: 5px; + margin-right: 5px; +} + +a.jp-restore-screen:hover { + background: url("<{$smarty.const.CORE_BASE_URL}>/images/multimedia/jplayer/jplayer.netcommons.jpg") -17px -64px no-repeat; +} + +a.jp-repeat { + display: none; +} + +a.jp-repeat-off { + display: none; +} + +a.jp-shuffle { + display: none; +} + +a.jp-shuffle-off { + display: none; +} + +/* @group NO SOLUTION error feedback */ + +.jp-no-solution { + padding:5px; + font-size:.8em; + background-color:#eee; + border:2px solid #009be3; + color:#000; + display:none; +} + +.jp-no-solution a { + color:#000; +} + +.jp-no-solution span { + font-size:1em; + display:block; + text-align:center; + font-weight:bold; +} + +/* @end */ diff --git a/multimedia/files/images/Jplayer.swf b/multimedia/files/images/Jplayer.swf new file mode 100644 index 0000000..aca11a5 Binary files /dev/null and b/multimedia/files/images/Jplayer.swf differ diff --git a/multimedia/files/images/jplayer/jplayer.blue.monday.jpg b/multimedia/files/images/jplayer/jplayer.blue.monday.jpg new file mode 100644 index 0000000..adab53f Binary files /dev/null and b/multimedia/files/images/jplayer/jplayer.blue.monday.jpg differ diff --git a/multimedia/files/images/jplayer/jplayer.blue.monday.seeking.gif b/multimedia/files/images/jplayer/jplayer.blue.monday.seeking.gif new file mode 100644 index 0000000..dbd2105 Binary files /dev/null and b/multimedia/files/images/jplayer/jplayer.blue.monday.seeking.gif differ diff --git a/multimedia/files/images/jplayer/jplayer.blue.monday.video.play.png b/multimedia/files/images/jplayer/jplayer.blue.monday.video.play.png new file mode 100644 index 0000000..8e97df0 Binary files /dev/null and b/multimedia/files/images/jplayer/jplayer.blue.monday.video.play.png differ diff --git a/multimedia/files/images/jplayer/jplayer.netcommons.jpg b/multimedia/files/images/jplayer/jplayer.netcommons.jpg new file mode 100644 index 0000000..59d821e Binary files /dev/null and b/multimedia/files/images/jplayer/jplayer.netcommons.jpg differ diff --git a/multimedia/files/images/jplayer/jplayer.netcommons.video.play.png b/multimedia/files/images/jplayer/jplayer.netcommons.video.play.png new file mode 100644 index 0000000..2ad92e4 Binary files /dev/null and b/multimedia/files/images/jplayer/jplayer.netcommons.video.play.png differ diff --git a/multimedia/files/images/jquery-1.7.1.min.js b/multimedia/files/images/jquery-1.7.1.min.js new file mode 100644 index 0000000..198b3ff --- /dev/null +++ b/multimedia/files/images/jquery-1.7.1.min.js @@ -0,0 +1,4 @@ +/*! jQuery v1.7.1 jquery.com | jquery.org/license */ +(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!ck[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cl||(cl=c.createElement("iframe"),cl.frameBorder=cl.width=cl.height=0),b.appendChild(cl);if(!cm||!cl.createElement)cm=(cl.contentWindow||cl.contentDocument).document,cm.write((c.compatMode==="CSS1Compat"?"":"")+"
"),cm.close();d=cm.createElement(a),cm.body.appendChild(d),e=f.css(d,"display"),b.removeChild(cl)}ck[a]=e}return ck[a]}function cu(a,b){var c={};f.each(cq.concat.apply([],cq.slice(0,b)),function(){c[this]=a});return c}function ct(){cr=b}function cs(){setTimeout(ct,0);return cr=f.now()}function cj(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ci(){try{return new a.XMLHttpRequest}catch(b){}}function cc(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;g| t |