#217 썸네일 생성 방법을 문서 모듈에서 crop/ratio를 정할 수 있게 하고 xe_webzine, xe_gallery에서 방식/가로/세로크기를 지정할 수 있게 함. newest_images 위젯 역시 동일한 설정과 동작을 추가함

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@2734 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2007-10-11 03:37:37 +00:00
parent e4d55fc4d1
commit 5bdad63b7f
28 changed files with 514 additions and 267 deletions

View file

@ -6,7 +6,10 @@
<action name="dispDocumentPreview" type="view" standalone="true" />
<action name="dispDocumentAdminList" type="view" admin_index="true" standalone="true" />
<action name="dispDocumentAdminConfig" type="view" standalone="true" />
<action name="procDocumentAdminDeleteChecked" type="controller" standalone="true" />
<action name="procDocumentAdminInsertConfig" type="controller" standalone="true" />
<action name="procDocumentAdminDeleteAllThumbnail" type="controller" standalone="true" />
</actions>
</module>

View file

@ -253,5 +253,44 @@
return new Object();
}
/**
* @brief 문서 모듈의 기본설정 저장
**/
function procDocumentAdminInsertConfig() {
// 기본 정보를 받음
$args = Context::gets('thumbnail_type');
// module Controller 객체 생성하여 입력
$oModuleController = &getController('module');
$output = $oModuleController->insertModuleConfig('document',$args);
return $output;
}
/**
* @brief 모든 생성된 썸네일 삭제
**/
function procDocumentAdminDeleteAllThumbnail() {
// files/attaches/images/ 디렉토리를 순환하면서 thumbnail_*.jpg 파일을 모두 삭제
$this->deleteThumbnailFile('./files/attach/images');
$this->setMessage('success_deleted');
}
function deleteThumbnailFile($path) {
$directory = dir($path);
while($entry = $directory->read()) {
if ($entry != "." && $entry != "..") {
if (is_dir($path."/".$entry)) {
$this->deleteThumbnailFile($path."/".$entry);
} else {
if(!eregi('^thumbnail_([^\.]*)\.jpg$',$entry)) continue;
@unlink($path.'/'.$entry);
}
}
}
$directory->close();
}
}
?>

View file

@ -77,5 +77,18 @@
$this->setTemplateFile('document_list');
}
/**
* @brief 문서 모듈 설정
**/
function dispDocumentAdminConfig() {
$oDocumentModel = &getModel('document');
$config = $oDocumentModel->getDocumentConfig();
Context::set('config',$config);
// 템플릿 파일 지정
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('document_config');
}
}
?>

View file

@ -23,6 +23,7 @@
$oModuleController = &getController('module');
$oModuleController->insertActionForward('document', 'view', 'dispDocumentAdminList');
$oModuleController->insertActionForward('document', 'view', 'dispDocumentPrint');
$oModuleController->insertActionForward('document', 'view', 'dispDocumentAdminConfig');
$oDB = &DB::getInstance();
$oDB->addIndex("documents","idx_module_list_order", array("module_srl","list_order"));
@ -38,6 +39,7 @@
**/
function checkUpdate() {
$oDB = &DB::getInstance();
$oModuleModel = &getModel('module');
/**
* 2007. 7. 23 : 확장변수(extra_vars1~20까지 추가)
@ -57,6 +59,11 @@
if(!$oDB->isIndexExists("documents","idx_module_readed_count")) return true;
if(!$oDB->isIndexExists("documents","idx_module_voted_count")) return true;
/**
* 2007. 10. 11 : 관리자 페이지의 기본 설정 Action 추가
**/
if(!$oModuleModel->getActionForward('dispDocumentAdminConfig')) return true;
return false;
}
@ -65,6 +72,8 @@
**/
function moduleUpdate() {
$oDB = &DB::getInstance();
$oModuleModel = &getModel('module');
$oModuleController = &getController('module');
/**
* 2007. 7. 23 : 확장변수(extra_vars1~20까지 추가)
@ -102,6 +111,12 @@
$oDB->addIndex("documents","idx_module_voted_count", array("module_srl","voted_count"));
}
/**
* 2007. 10. 11 : 관리자 페이지의 기본 설정 Action 추가
**/
if(!$oModuleModel->getActionForward('dispDocumentAdminConfig'))
$oModuleController->insertActionForward('document', 'view', 'dispDocumentAdminConfig');
return new Object(0,'success_updated');
}

View file

@ -288,12 +288,12 @@
return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin);
}
function thumbnailExists($width = 80, $height = 0) {
if(!$this->getThumbnail($width, $height)) return false;
function thumbnailExists($width = 80, $height = 0, $type = '') {
if(!$this->getThumbnail($width, $height, $type)) return false;
return true;
}
function getThumbnail($width = 80, $height = 0) {
function getThumbnail($width = 80, $height = 0, $thumbnail_type = '') {
if(!$height) $height = $width;
// 문서의 이미지 첨부파일 위치를 구함
@ -315,6 +315,13 @@
// 썸네일 파일이 있으면 url return
if(file_exists($thumbnail_file)) return Context::getRequestUri().$thumbnail_file;
// 문서 모듈의 기본 설정에서 Thumbnail의 생성 방법을 구함
if(!in_array($thumbnail_type, array('crop','ratio'))) {
$oDocumentModel = &getModel('document');
$config = $oDocumentModel->getDocumentConfig();
$thumbnail_type = $config->thumbnail_type;
}
// 생성 시작
FileHandler::writeFile($thumbnail_file, '', 'w');
@ -330,7 +337,7 @@
$filename = $file->uploaded_filename;
if(!file_exists($filename)) continue;
FileHandler::createImageFile($filename, $thumbnail_file, $width, $height, 'jpg');
FileHandler::createImageFile($filename, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type);
if(file_exists($thumbnail_file)) return Context::getRequestUri().$thumbnail_file;
}
}
@ -353,7 +360,7 @@
return;
}
FileHandler::createImageFile($tmp_file, $thumbnail_file, $width, $height, 'jpg');
FileHandler::createImageFile($tmp_file, $thumbnail_file, $width, $height, 'jpg', $config->thumbnail_type);
@unlink($tmp_file);
return Context::getRequestUri().$thumbnail_file;

View file

@ -312,5 +312,20 @@
return $output;
}
/**
* @brief 문서 설정 정보를 구함
**/
function getDocumentConfig() {
if(!$GLOBLAS['__document_config__']) {
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('document');
if(!$config->thumbnail_type) $config->thumbnail_type = 'crop';
$GLOBLAS['__document_config__'] = $config;
}
return $GLOBLAS['__document_config__'];
}
}
?>

View file

@ -5,6 +5,12 @@
* @brief Document module's basic language pack
**/
$lang->document_list = 'Document list';
$lang->thumbnail_type = 'Thumbnail Type';
$lang->thumbnail_crop = 'Crop';
$lang->thumbnail_ratio = 'Ratio';
$lang->cmd_delete_all_thumbnail = 'Delete all thumbnails';
$lang->cmd_toggle_checked_document = '선택항목 반전';
$lang->cmd_delete_checked_document = 'Delete selected';

View file

@ -5,6 +5,12 @@
* @sumario Paquete del idioma español para el módulo de documentos.
**/
$lang->document_list = 'Document list';
$lang->thumbnail_type = 'Thumbnail Type';
$lang->thumbnail_crop = 'Crop';
$lang->thumbnail_ratio = 'Ratio';
$lang->cmd_delete_all_thumbnail = 'Delete all thumbnails';
$lang->cmd_toggle_checked_document = '선택항목 반전';
$lang->cmd_delete_checked_document = 'Eliminar lo seleccionado';

View file

@ -5,6 +5,12 @@
* @brief ドキュメントdocumentモジュルの基本言語パッケージ
**/
$lang->document_list = 'Document list';
$lang->thumbnail_type = 'Thumbnail Type';
$lang->thumbnail_crop = 'Crop';
$lang->thumbnail_ratio = 'Ratio';
$lang->cmd_delete_all_thumbnail = 'Delete all thumbnails';
$lang->cmd_toggle_checked_document = '선택항목 반전';
$lang->cmd_delete_checked_document = '選択項目削除';

View file

@ -5,6 +5,12 @@
* @brief 문서(document) 모듈의 기본 언어팩
**/
$lang->document_list = '문서 목록';
$lang->thumbnail_type = '썸네일 생성 방법';
$lang->thumbnail_crop = '잘라내기 (정해진 크기에 꽉 찬 모습의 썸네일을 만듭니다)';
$lang->thumbnail_ratio = '비율 맞추기 (원본 이미지의 비율에 맞춥니다. 다만 정해진 크기에 여백이 생깁니다)';
$lang->cmd_delete_all_thumbnail = '썸네일 모두 삭제';
$lang->cmd_toggle_checked_document = '선택항목 반전';
$lang->cmd_delete_checked_document = '선택항목 삭제';

View file

@ -5,6 +5,12 @@
* @brief 文章(document)模块语言包
**/
$lang->document_list = 'Document list';
$lang->thumbnail_type = 'Thumbnail Type';
$lang->thumbnail_crop = 'Crop';
$lang->thumbnail_ratio = 'Ratio';
$lang->cmd_delete_all_thumbnail = 'Delete all thumbnails';
$lang->cmd_toggle_checked_document = '反选';
$lang->cmd_delete_checked_document = '删除所选';

View file

@ -0,0 +1,24 @@
<!--#include("header.html")-->
<!--%import("filter/insert_config.xml")-->
<form action="./" method="get" onsubmit="return procFilter(this, insert_config)">
<table cellspacing="0" class="tableType2 gap1">
<col width="200" />
<col />
<tr>
<th scope="col">{$lang->thumbnail_type}</th>
<td>
<input type="radio" name="thumbnail_type" value="crop" <!--@if($config->thumbnail_type != 'ratio')-->checked="checked"<!--@end-->/> {$lang->thumbnail_crop} <br />
<input type="radio" name="thumbnail_type" value="ratio" <!--@if($config->thumbnail_type == 'ratio')-->checked="checked"<!--@end-->/> {$lang->thumbnail_ratio}
</td>
</tr>
</table>
<!-- 버튼 -->
<div class="fl gap1">
<span class="button"><input type="button" value="{$lang->cmd_delete_all_thumbnail}" onclick="doDeleteAllThumbnail(); return false;"/></span>
</div>
<div class="fr gap1">
<span class="button"><input type="submit" value="{$lang->cmd_registration}" accesskey="s" /></span>
</div>
</form>

View file

@ -1,7 +1,6 @@
<!--%import("filter/delete_checked.xml")-->
<!--%import("js/document_admin.js")-->
<!--#include("header.html")-->
<h3>{$lang->document} <span class="gray">{$lang->cmd_management}</span></h3>
<!-- 정보 -->
<div class="tableSummaryType1">

View file

@ -0,0 +1,7 @@
<filter name="insert_config" module="document" act="procDocumentAdminInsertConfig" confirm_msg_code="confirm_submit">
<form />
<response>
<tag name="error" />
<tag name="message" />
</response>
</filter>

View file

@ -0,0 +1,10 @@
<!--%import("js/document_admin.js")-->
<h3>{$lang->document} <span class="gray">{$lang->cmd_management}</span></h3>
<div class="header4">
<ul class="localNavigation">
<li <!--@if($act=='dispDocumentAdminList')-->class="on"<!--@end-->><a href="{getUrl('act','dispDocumentAdminList')}">{$lang->document_list}</a></li>
<li <!--@if($act=='dispDocumentAdminConfig')-->class="on"<!--@end-->><a href="{getUrl('act','dispDocumentAdminConfig')}">{$lang->cmd_module_config}</a></li>
</ul>
</div>

View file

@ -6,4 +6,16 @@ function doCheckAll(bToggle) {
if( !fo_obj[i].checked || !bToggle) fo_obj[i].checked = true; else fo_obj[i].checked = false;
}
}
}
}
/**
* @brief 모든 생성된 썸네일 삭제하는 액션 호출
**/
function doDeleteAllThumbnail() {
exec_xml('document','procDocumentAdminDeleteAllThumbnail',new Array(), completeDeleteAllThumbnail);
}
function completeDeleteAllThumbnail(ret_obj) {
alert(ret_obj['message']);
location.reload();
}