묻고답하기

사용된 위젯의 원본은

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 남기남
로엘로니 로그인폼의 메뉴를 팝업창으로 ! [1] 2008.11.23 by findwind
Research 500에러때문에 설치 중단... [2] 2008.11.23 by Research
철쌤 홈페이지 패키지에 관한 질문... [2] 2008.11.23 by 철쌤
Pizza527 기본 레이아웃 폰트 색은 어디서 바꾸나요? [1] file 2008.11.23 by 넨네
공듀 회원가입후 이름과 이메일주소 수정변경 방법.. [2] 2008.11.23 by 공듀
&d 제로보드xe 관리자 로그인, 아이디비밀번호 찾기 문제 [2] 2008.11.23 by &d
&d 웹에 업로드 할때 [2] 2008.11.23 by &d
&d 회원가입, 로그인창 및 삭제 알림창 양식 스킨변경(색상변경) [2] file 2008.11.23 by &d
&d 스킨 수정 - 글색상 변경 [2] file 2008.11.23 by &d
oO나쁜토끼Oo mid와 게시판 연동이..ㅠ_ㅠ [1] file 2008.11.23 by 엠™
&d 사랑비 관리자 초기암호 문제 [1] 2008.11.23 by 센세이션
블루즈 layout template handler? 질문 [1] 2008.11.23 by 센세이션
저먼하늘아래 외부 페이지, 페이지 생성시 레이아웃  
왕왕초보 도움 청합니다. 첨부파일이,,,, [1] 2008.11.23 by 센세이션
fldfkero 최근게시물 탭형태가 뜨지 않습니다 ㅠㅠ [1] file 2008.11.23 by SMaker
earthhero.me 이미지를 다른곳에서 링크 걸었을경우 저의 트래픽이 되나요? [2] 2008.11.23 by earthhero.me
중년 php5로 이전후 100개 이상 리스트 소스 적용이 안됩니다.  
kim 방문자 경로 리퍼러 통계  
센세이션 플래닛에서 작성한 글 미투데이로 발송하려는데. [3] file 2008.11.23 by 센세이션
한재은 그림과 같이 메뉴를 구성하고 싶은데요. [2] 2008.11.23 by 한재은