묻고답하기
변수를 호출하고싶습니다!
2014.11.05 04:32
다운로드 랭킹 위젯에서
다운로드랭킹 위젯 정보와 더불어 플래시 플레이어를 뿌려주기 위하여 업로드한 파일들의
$oDocument->hasUploadedFiles() 를 선언해야하는데
위젯의 class.php 파일에
//추가
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument($obj->upload_target_srl, false, false);
이런식으로 변수를 추가하고
list.html 부분에 아래 태그를 입력해도
upload된 파일들을 읽지 못하는 것 같습니다.
위젯에서 업로드된 파일들을 불러오려면 어떻게 해야할까요??
<!--// musicplayer(mKAEkr, 2014-08-11) -->
<block cond="$oDocument->hasUploadedFiles()">
{@
$AttachmentList = $oDocument->hasUploadedFiles();
$attachment_loop = 0;
$allow_extension = array('mp3', 'wav');
$replace_text_target = array("'", '"');
$replace_text_needle = array(''', '"');
}
<?php
/**
* @class rank_download
* @author Simulz.com (k10206@naver.com)
* @brief 파일 다운로드 랭킹
**/
class rank_download extends WidgetHandler {
/**
* @brief 위젯의 실행 부분
*
* ./widgets/위젯/conf/info.xml 에 선언한 extra_vars를 args로 받는다
* 결과를 만든후 print가 아니라 return 해주어야 한다
**/
function proc($args) {
// 대상 모듈 (mid_list는 기존 위젯의 호환을 위해서 처리하는 루틴을 유지. module_srls로 위젯에서 변경)
$oModuleModel = &getModel('module');
if($args->mid_list) {
$mid_list = explode(",",$args->mid_list);
if(count($mid_list)) {
$module_srls = $oModuleModel->getModuleSrlByMid($mid_list);
if(count($module_srls)) $args->module_srls = implode(',',$module_srls);
else $args->module_srls = null;
}
}
//추가
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument($obj->upload_target_srl, false, false);
// 제목
$title = $args->title;
// 정렬 대상
$order_target = $args->order_target;
// 정렬 순서
$order_type = $args->order_type;
if(!in_array($order_type, array('asc','desc'))) $order_type = 'asc';
// 출력된 목록 수
$list_count = (int)$args->list_count;
if(!$list_count) $list_count = 5;
// 대상 모듈이 선택되어 있지 않으면 해당 사이트의 전체 모듈을 대상으로 함
$site_module_info = Context::get('site_module_info');
if($args->module_srls) $obj->module_srl = $args->module_srls;
else if($site_module_info) $obj->site_srl = (int)$site_module_info->site_srl;
// FileModel::getFileList()를 이용하기 위한 변수 정리
$obj->direct_download = ($args->attach_type == "noimage") ? "N": (($args->attach_type == "image") ? "Y" : "");
if($args->without_image == "true") $obj->direct_download = "N";
$obj->list_count = $list_count;
$obj->sort_index = $order_target;
$obj->order_type = $args->order_type;
// 다운로드 횟수 1이상만 검색
$obj->download_count = 1;
if($args->regdate) $obj->regdate = date("Ymd", strtotime("-{$args->regdate} day"));
$output = executeQueryArray('widgets.rank_download.getFileList', $obj);
// 오류가 생기면 그냥 무시
if(!$output->toBool()) ;
$oFileModel = &getModel('file');
if(count($output->data)) {
foreach($output->data as $key => $val) {
$file = $val;
$file->download_url = $oFileModel->getDownloadUrl($val->file_srl, $val->sid);
$file->source_filename = htmlspecialchars($val->source_filename);
if($args->short_title && !preg_match("/[^0-9]/", $args->short_title))
{
if(!$args->short_type) $args->short_type = "...";
if($args->ext_option != "Y")
$file->source_filename = cut_str($file->source_filename, $args->short_title, $args->short_type);
else
{
preg_match("/\.[a-zA-Z0-9_]+$/", $val->source_filename, $ext);
$newTitle = substr($val->source_filename, 0, strlen($val->source_filename)-strlen($ext[0]));
$file->source_filename = cut_str($newTitle, $args->short_title, $args->short_type).$ext[0];
}
}
$file_list[$key] = $file;
}
}
$widget_info->title = $title;
$widget_info->list_count = $list_count;
$widget_info->file_list = $file_list;
$widget_info->download = $args->download == "Y" ? true : false;
$widget_info->subject_cut_size = $subject_cut_size;
Context::set('widget_info', $widget_info);
// 템플릿의 스킨 경로를 지정 (skin, colorset에 따른 값을 설정)
$tpl_path = sprintf('%sskins/%s', $this->widget_path, $args->skin);
Context::set('colorset', $args->colorset);
// 템플릿 파일을 지정
$tpl_file = 'list';
// 템플릿 컴파일
$oTemplate = &TemplateHandler::getInstance();
$output = $oTemplate->compile($tpl_path, $tpl_file);
return $output;
}
}
?>
<!--// 설정된 컬러셋의 종류에 따라서 css파일을 import 합니다 -->
<!--%import("css/default.css")-->
<div class="sz_download">
<div class="sz_{$colorset}">
<!--@if($widget_info->title)-->
<h2>{$widget_info->title} Top {$widget_info->list_count}</h2>
<!--@end-->
<!--@if(count($widget_info->file_list))-->
<ul>
{@ $no = 1}
<!--@foreach($widget_info->file_list as $val)-->
<li>
<div class="title">{$no}위. <a href="{getUrl('','document_srl',$val->upload_target_srl)}">{$val->source_filename} ({FileHandler::filesize($val->file_size)})</a></div>
<!--@if($widget_info->download)--><div class="download"><a href="{$val->download_url}" onClick="return (confirm('다운시 포인트가 차감됩니다'))?true:false">
[다운]</a></div><!--@end-->
<div class="count">{$val->download_count}회</div>
<div class="clear"></div>
</li>
{@ $no++}
<!--@end-->
</ul>
<!--@end-->
</div>
</div>