Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feat: improve availability #48

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions Controller/MultidatabaseContentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Tomoyuki OHNO (Ricksoft Co., Ltd.) <ohno.tomoyuki@ricksoft.jp>
* @author Kazunori Sakamoto <exkazuu@willbooster.com>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
Expand All @@ -18,6 +19,7 @@
* MultidatabaseContentsController Controller
*
* @author Tomoyuki OHNO (Ricksoft Co., Ltd.) <ohno.tomoyuki@ricksoft.jp>
* @author Kazunori Sakamoto <exkazuu@willbooster.com>
* @package NetCommons\Multidatabases\Controller
*/
class MultidatabaseContentsController extends MultidatabasesAppController {
Expand Down Expand Up @@ -134,7 +136,7 @@ public function beforeFilter() {
$this->set('multidatabaseFrameSetting', $frameSetting['MultidatabaseFrameSetting']);

// ゲストアクセスOKのアクションを設定
$this->Auth->allow('index', 'detail', 'search');
$this->Auth->allow('index', 'detail', 'search', 'get_download_count');

$this->_prepare();
}
Expand Down Expand Up @@ -404,6 +406,29 @@ public function download() {
return $this->Download->doDownload($contentId, $options);
}

/**
* File Download Count
* ファイルダウンロード数
*
* @return void
*/
public function get_download_count() {
$query = [
'fields' => [
'UploadFile.total_download_count',
],
'conditions' => [
'UploadFile.id' => $this->request->query('upload_file_id'),
],
'recursive' => -1
];
$UploadFile = ClassRegistry::init('Files.UploadFile');
$file = $UploadFile->find('first', $query);

$this->set('_serialize', ['count']);
$this->set('count', $file);
}

/**
* Search
* 検索
Expand Down Expand Up @@ -564,5 +589,3 @@ private function __list($extraConditions = []) {
$this->set('viewMode', 'list');
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<?php
echo $this->NetCommonsHtml->script([
'/multidatabases/js/edit_multi_database_metadatas.js',
'/multidatabases/js/edit_multidatabase_metadatas.js',
]);
?>

Expand Down
13 changes: 11 additions & 2 deletions View/Helper/MultidatabaseContentViewElementHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Tomoyuki OHNO (Ricksoft Co., Ltd.) <ohno.tomoyuki@ricksoft.jp>
* @author Kazunori Sakamoto <exkazuu@willbooster.com>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
Expand All @@ -17,6 +18,7 @@
* MultidatabaseContentViewElementHelper Helper
*
* @author Tomoyuki OHNO (Ricksoft, Co., LTD.) <ohno.tomoyuki@ricksoft.jp>
* @author Kazunori Sakamoto <exkazuu@willbooster.com>
* @package NetCommons\Multidatabase\View\Helper
*
*/
Expand All @@ -29,6 +31,7 @@ class MultidatabaseContentViewElementHelper extends AppHelper {
*/
public $helpers = [
'NetCommons.Button',
'NetCommons.CDNCache',
'NetCommons.NetCommonsHtml',
'NetCommons.NetCommonsForm',
'Form',
Expand Down Expand Up @@ -167,8 +170,14 @@ private function __renderViewElementFile($content, $colNo, $showCounter = 0) {
$result = $this->__renderViewElementFileReqAuth($content, $colNo, $fileInfo);
}
if ((int)$showCounter === 1) {
$result .= '&nbsp;<span class="badge">';
$result .= $fileInfo['UploadFile']['total_download_count'];
$initialValue = $this->CDNCache->isCacheable() ? null : $fileInfo['UploadFile']['total_download_count'];
$result .= $this->NetCommonsHtml->script('/multidatabases/js/multidatabase_files.js');
$result .= '&nbsp;<span class="badge" ng-controller="MultidatabaseFile.view" ng-cloak';
$result .= ' ng-init="init(' . h(json_encode(Current::read('Frame.id')));
$result .= ',' . h(json_encode($fileInfo['UploadFile']['id']));
$result .= ',' . h(json_encode($initialValue));
$result .= ');">';
$result .= '{{downloadCount}}';
$result .= '</span>';
}

Expand Down
4 changes: 2 additions & 2 deletions View/MultidatabaseContents/form.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

if ($this->MultidatabaseContentEdit->chkHaveWysiwygItems($multidatabaseMetadata)) {
echo $this->NetCommonsHtml->script([
'/multidatabases/js/edit_multi_database_contents.js',
'/multidatabases/js/edit_multidatabase_contents.js',
]);
} else {
echo $this->NetCommonsHtml->script([
'/multidatabases/js/edit_multi_database_contents_without_wysiwyg.js',
'/multidatabases/js/edit_multidatabase_contents_without_wysiwyg.js',
]);
}

Expand Down
Empty file removed webroot/css/empty
Empty file.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
* Multidatabases DatabaseContents JS
* コンテンツ編集関連フロントエンド処理
* webroot/js/edit_multi_database_contents.js
* webroot/js/edit_multidatabase_contents.js
*
* @author ohno.tomoyuki@ricksoft.jp (Tomoyuki OHNO/Ricksoft, Co., Ltd.)
* @author exkazuu@willbooster.com (Kazunori Sakamoto)
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
* Multidatabases DatabaseContentsWithoutWysiwyg JS
* コンテンツ編集関連フロントエンド処理(Wysiwygなしの場合)
* webroot/js/edit_multi_database_contents.js
* webroot/js/edit_multidatabase_contents.js
*
* @author ohno.tomoyuki@ricksoft.jp (Tomoyuki OHNO/Ricksoft, Co., Ltd.)
* @author exkazuu@willbooster.com (Kazunori Sakamoto)
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
* Multidatabases DatabaseMetadatas JS
* メタデータ編集関連フロントエンド処理
* webroot/js/edit_multi_database_metadatas.js
* webroot/js/edit_multidatabase_metadatas.js
*
* @author ohno.tomoyuki@ricksoft.jp (Tomoyuki OHNO/Ricksoft, Co., Ltd.)
* @author exkazuu@willbooster.com (Kazunori Sakamoto)
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
*/
Expand Down
Empty file removed webroot/js/empty
Empty file.
28 changes: 28 additions & 0 deletions webroot/js/multidatabase_files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Multidatabases Files JS
*
* @author exkazuu@willbooster.com (Kazunori Sakamoto)
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
*/

NetCommonsApp.controller('MultidatabaseFile.view',
['$scope', '$http', 'NC3_URL', function($scope, $http, NC3_URL) {

$scope.downloadCount = '-';

$scope.init = function(frameId, uploadFileId, initialValue) {
if (initialValue !== null) {
$scope.downloadCount = initialValue;
return;
}
var params = '?frame_id=' + frameId + '&upload_file_id=' + uploadFileId;
$http.get(NC3_URL + '/multidatabases/multidatabase_contents/get_download_count.json' + params)
.then(
function(response) {
$scope.downloadCount = response.data.count.UploadFile.total_download_count;
},
function() {
});
};
}]);