* @author Tomoyuki OHNO (Ricksoft Co., Ltd.)
', $value);
}
$value = nl2br($value);
return $value;
}
/**
* WYSIWYGの値を出力する
*
* @param array $content コンテンツ配列
* @param int $colNo カラムNo
* @return string HTML
*/
private function __renderViewElementWysiwyg($content, $colNo) {
return $content['MultidatabaseContent']['value' . $colNo];
}
/**
* 日付の値を出力する
*
* @param array $content コンテンツ配列
* @param int $colNo カラムNo
* @param string $type 種別(created, updated, その他)
* @return string HTML
*/
private function __renderViewElementDate($content, $colNo, $type = null) {
$netCommonsTime = new NetCommonsTime();
switch ($type) {
case 'created':
// 作成日時を出力
return $netCommonsTime->toUserDatetime($content['MultidatabaseContent']['created']);
case 'updated':
// 更新日時を出力
return $netCommonsTime->toUserDatetime($content['MultidatabaseContent']['modified']);
default:
$value = $this->__renderViewElementGeneral($content, $colNo);
// 空 or DateTime型以外は、空セット
if (empty($value)) {
return '';
} elseif (! $netCommonsTime->isDatetime($value)) {
return '';
}
return $netCommonsTime->toUserDatetime($value);
}
}
/**
* ファイルアップロードの値を出力する
*
* @param array $content コンテンツ配列
* @param int $colNo カラムNo
* @param int $showCounter カウンターを表示するか 1:表示する
* @return string HTML
*/
private function __renderViewElementFile($content, $colNo, $showCounter = 0) {
// アップロードされたファイルのリンクを表示&パスワード入力ダイアログ
if (! $fileInfo = $this->__getFileInfo($content, $colNo)) {
return '';
}
$ContentFile = ClassRegistry::init('Multidatabases.MultidatabaseContentFile');
if (! $ContentFile->getAuthKey(
$content['MultidatabaseContent']['id'], 'value' . $colNo)
) {
$fileUrl = $this->__fileDlUrl($content, $colNo);
$result = ' ';
$result .= '';
// 表示が全てダウンロードとなる。ファイル名を表示する
//$result .= __d('multidatabases', 'Download');
$result .= h($fileInfo['UploadFile']['original_name']);
$result .= '';
} else {
$result = $this->__renderViewElementFileReqAuth($content, $colNo, $fileInfo);
}
if ((int)$showCounter === 1) {
$result .= ' ';
$result .= $fileInfo['UploadFile']['total_download_count'];
$result .= '';
}
return $result;
}
/**
* ファイルアップロードの値を出力する(認証が必要な場合)
*
* @param array $content コンテンツ配列
* @param int $colNo カラムNo
* @param array $fileInfo ダウンロードファイル
* @return string HTML
*/
private function __renderViewElementFileReqAuth($content, $colNo, $fileInfo) {
// 認証キー必要
$result = ' ';
$result .= $this->NetCommonsHtml->link(
// 表示が全てダウンロードとなる。ファイル名を表示する
//__d('multidatabases', 'Download'),
$fileInfo['UploadFile']['original_name'],
'#',
[
'authorization-keys-popup-link',
'url' => NetCommonsUrl::actionUrl($this->__fileDlArrayReqAuth($content, $colNo)),
'frame-id' => Current::read('Frame.id'),
'popup-title' => __d('authorization_keys', 'Authorization key confirm dialog'),
'popup-label' => __d('authorization_keys', 'Authorization key'),
'popup-placeholder' =>
__d('authorization_keys', 'Please input authorization key'),
]
);
return $result;
}
/**
* 画像用のファイルアップロードの値を出力する
*
* @param array $content コンテンツ配列
* @param int $colNo カラムNo
* @return string HTML
*/
private function __renderViewElementImage($content, $colNo) {
// アップロードされた画像を表示
if (! $this->__getFileInfo($content, $colNo)) {
return '';
}
$fileUrl = $this->__fileDlUrl($content, $colNo);
$result = '';
return $result;
}
/**
* リンクの値を出力する
*
* @param array $content コンテンツ配列
* @param int $colNo カラムNo
* @return string HTML
*/
private function __renderViewElementLink($content, $colNo) {
$value = $this->__renderViewElementGeneral($content, $colNo);
$result = '' . $value . '';
return $result;
}
/**
* メールアドレスの値を出力する
*
* @param array $content コンテンツ配列
* @param int $colNo カラムNo
* @return string HTML
*/
private function __renderViewElementEmail($content, $colNo) {
$value = $this->__renderViewElementGeneral($content, $colNo);
$result = '' . $value . '';
return $result;
}
/**
* 自動採番の値を出力する
*
* @param array $content コンテンツ配列
* @param int $colNo カラムNo
* @return string HTML
*/
private function __renderViewElementAutoNumber($content, $colNo) {
// 自動採番のフィールドを作成してここに表示させる
return $this->__renderViewElementGeneral($content, $colNo);
}
/**
* ファイルダウンロードURL出力用の配列を返す
*
* @param array $content コンテンツ配列
* @param int $colNo カラムNo
* @return array
*/
private function __fileDlArray($content, $colNo) {
return [
'controller' => 'multidatabase_contents',
'action' => 'download',
$content['MultidatabaseContent']['key'],
$content['MultidatabaseContent']['id'],
'?' => ['col_no' => $colNo]
];
}
/**
* ファイルダウンロードURL出力用の配列を返す(認証あり)
*
* @param array $content コンテンツ配列
* @param int $colNo カラムNo
* @return array
*/
private function __fileDlArrayReqAuth($content, $colNo) {
return [
'controller' => 'multidatabase_contents',
'action' => 'download',
Current::read('Block.id'),
$content['MultidatabaseContent']['key'],
$content['MultidatabaseContent']['id'],
'?' => [
'col_no' => $colNo,
'frame_id' => Current::read('Frame.id')
]
];
}
/**
* ファイルダウンロードURLを出力する
*
* @param array $content コンテンツ配列
* @param int $colNo カラムNo
* @return string HTML
*/
private function __fileDlUrl($content, $colNo) {
return $this->NetCommonsHtml->url(
$this->__fileDlArray($content, $colNo)
);
}
/**
* ダウンロードファイルが存在するかチェックする
*
* @param array $content コンテンツ配列
* @param int $colNo カラムNo
* @return bool|array
*/
private function __getFileInfo($content, $colNo) {
if (
empty($content['MultidatabaseContent']['id']) ||
empty($colNo)
) {
return false;
}
$UploadFile = ClassRegistry::init('Files.UploadFile');
$pluginKey = 'multidatabases';
$file = $UploadFile->getFile(
$pluginKey,
$content['MultidatabaseContent']['id'],
'value' . $colNo . '_attach'
);
if (! empty($file)) {
return $file;
}
return false;
}
}