묻고답하기

사용된 위젯의 원본은

http://www.xpressengine.com/index.php?&mid=download&search_keyword=%EB%9E%AD%ED%82%B9&package_srl=18324351

위 주소에서 받아서 사용하였습니다.

질문의 요지는 현재 위 위젯은 전체 모든 기간에서 다운로드 랭킹이 높은 목록을 출력하는데

이렇게 되면 상위에 있던 게시물이 계속 상위권에 머물르기 때문에 7일내로 목록을 출력하고자 합니다.

 

 

[기본소스]

rank_download.class

<?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;
                }
            }

            // 제목
            $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;

            $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);
                    $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;
        }
    }
?>

위 중간에 부분에

   //추가 7일이내의 게시물만 검색
   $db_args->regdate = date("Ymd", mktime(0, 0, 0, date('m'), date('d')-7, date('Y')));
               $db_args->sort_index = 'readed_count';
            $db_args->order_type = 'desc';
            $output = executeQueryArray('widgets.rank_download.getFileList', $db_args);
            if($output->data) {
                foreach($output->data as $k => $v) {
                    $oDocument = null;
                    $oDocument = $oDocumentModel->getDocument();
                    $oDocument->setAttribute($v, false);
                    $GLOBALS['XE_DOCUMENT_LIST'][$oDocument->document_srl] = $oDocument;
                    $output->data[$k] = $oDocument;
                }
                $oDocumentModel->setToAllDocumentExtraVars();
            }
            $widget_info->popular_documents = $output->data;

            Context::set('widget_info', $widget_info);

를 추가하고

 

 

[기본소스]

getFileList.xml

<query id="getFileList" action="select">
    <tables>
        <table name="files" />
        <table name="modules" />
    </tables>
    <columns>
        <column name="files.*" />
    </columns>
    <conditions>

        <condition operation="equal" column="modules.site_srl" var="site_srl" />
        <condition operation="in" column="modules.module_srl" var="module_srl" pipe="and" />
        <condition operation="equal" column="files.module_srl" default="modules.module_srl" pipe="and" />
        <condition operation="equal" column="files.isvalid" default="Y" pipe="and" />
        <condition operation="more" column="files.download_count" var="download_count" pipe="and" />
        <condition operation="equal" column="files.direct_download" var="direct_download" pipe="and" />
    </conditions>
    <navigation>
        <index var="sort_index" default="files.download_count" order="desc" />
        <list_count var="list_count" default="20" />
    </navigation>
</query>

위 내용부분에도

  <condition operation="more" column="regdate" var="regdate" filter="number" pipe="and" />
 

내용을 추가했는데 다른 분들이 작성한 것을 짜집기해서 그런지 ㅠ_ㅠ 실제로 적용이 안되는데

rank_download.class

아무래도 이부분이 잘못된 것 같은데 php에 p도 모르는 무지한 사람입니다 죄송합니다.

어떻게 수정을 해야 할까요 조언좀 부탁드립니다 ㅠ_ㅠ
아울러 날씨 추운데 감기 조심하세요

 

글쓴이 제목 최종 글
XE 공지 글 쓰기,삭제 운영방식 변경 공지 [16] 2019.03.05 by 남기남
lo마음ve 최신이미지 썸네일관련 [1] 2008.11.22 by 백성찬
sakurastorm 외부로그인 관련 질문입니다! [8] file 2008.11.22 by 미누7
풀카운트 홈페이지가 안 열리는데요. [1] 2008.11.22 by 백성찬
중년 1.1.0업후 하단에 공백이 있습니다.  
얼쑤좋구나 [해결] 로그인 두번 해야되는 문제 도움 부탁드립니다. [5] 2008.11.22 by 얼쑤좋구나
얼쑤좋구나 [해결]회원 등급이 저절로 강등되는 문제 문의요 [1] 2008.11.22 by 얼쑤좋구나
궁금 플래닛 생성 방법 ??? [3] file 2008.11.22 by 저먼하늘아래
윤철기 메인페이지 로딩 속도 문의좀 드리겠습니다~ [1] 2008.11.22 by 느까끼
안미나 수정에 관한 질문입니다. [1] 2008.11.22 by 느까끼
홈피가이 급합니다. xe1.1.0설치후 잘못 건드려 다시 설치하기위해... [1] 2008.11.22 by zeroboardxe
김용준129 최근게시물 색지정시... [1] 2008.11.22 by zeroboardxe
중년 1.1.0 업후 게시판 조회수 변경은?  
서성진856 지식인 게시판 만드는법?  
유지은 rss관련 질문좀 드릴께요.  
111291 질문입니다 호스팅선택 [8] 2008.11.22 by 엠™
miso777 제로보드설치 PUTTY 업로드 오류문제 [3] file 2008.11.22 by miso777
인끈 아쿠라 유리버튼 스킨적용이 안되는 원인좀....  
서성진856 다른 분들도 이러시는지? [1] 2008.11.22 by 오프로더
슬픈동화 페이지 만들어서 최근 게시글 뽑을 때.. [2] 2008.11.22 by 슬픈동화
아스다 스타일 편집기창의 글씨가 작거나 커보이는 현상  
최관수905 xe 게시판 생성이 안되네요 [3] 2008.11.22 by 백성찬
두기 gallery2의 랜덤이미지 삽입  
원참치 어떤 분 답변중에 이해가 안가는 부분이.. [3] 2008.11.22 by 원참치
오대은 아무것도 안나와요 [4] 2008.11.22 by 오대은
레스키 가입시에 이름 기입 폼 제거 [1] 2008.11.22 by 느까끼
이가우 Query ID값이 잘못 지정되었습니다. 문의 [1] 2020.03.14 by 이가우
전국구 폰트크기조절은? [7] file 2008.11.22 by 전국구
김태운555 XE ver 1.1.0으로 업데이트 했는데 파일업로드 에러입니다 [2] file 2008.11.22 by 김태운555
전국구 이문제는 아무도 모르는건가요? [4] file 2008.11.22 by 전국구
Research zb4와 zbxe... 어느게 더 나을까요? [5] 2008.11.22 by Research