예제 #1
0
    def genernate_resoure_content(self, webpart):
        cache_key = "unit" + str(self.unit.unitId) + "_" + str(
            webpart.getUnitWebpartId())
        content = cache.get(cache_key)
        if content != None:
            request.setAttribute(cache_key, content)
            return

        map = HashMap()
        #最新资源
        qry = ResourceQuery(
            """ r.resourceId, r.title, r.href, r.createDate, r.fsize, r.downloadCount, 
            r.userId, r.subjectId as subjectId, grad.gradeName, sc.name as scName """
        )
        #qry.unitId = self.unit.unitId
        qry.custormAndWhereClause = " r.approvedPathInfo Like '%/" + str(
            self.unit.unitId) + "/%' "
        new_resource_list = qry.query_map(10)
        map.put("new_resource_list", new_resource_list)

        #本周热门资源
        qry = ResourceQuery(
            """ r.resourceId, r.title, r.href, r.createDate, r.fsize, r.downloadCount, 
            r.userId, msubj.msubjName, grad.gradeName, sc.name as scName """)
        qry.orderType = 4  # downloadCount DESC
        #qry.unitId = self.unit.unitId
        qry.custormAndWhereClause = " r.approvedPathInfo Like '%/" + str(
            self.unit.unitId) + "/%' "
        hot_resource_list = qry.query_map(10)
        map.put("hot_resource_list", hot_resource_list)

        #hot_resource_list = self.viewcount_svc.getViewCountListShared(12,7,10,self.unit.unitPath,self.unit.unitDepth);
        #map.put("hot_resource_list", hot_resource_list)

        # 推荐资源
        qry = ResourceQuery(
            """ r.resourceId, r.title, r.href, r.createDate, r.fsize, r.downloadCount, 
            r.userId,msubj.msubjName, grad.gradeName, sc.name as scName """)
        #qry.rcmdState = True
        #qry.unitId = self.unit.unitId
        qry.custormAndWhereClause = " r.approvedPathInfo Like '%/" + str(
            self.unit.unitId) + "/%' And r.rcmdPathInfo Like '%/" + str(
                self.unit.unitId) + "/%' "
        rcmd_resource_list = qry.query_map(10)
        map.put("rcmd_resource_list", rcmd_resource_list)

        map.put("unit", self.unit)
        map.put("webpart", webpart)
        map.put("UnitRootUrl", self.unitRootUrl)
        content = self.templateProcessor.processTemplate(
            map, "/WEB-INF/unitspage/" + self.templateName + "/resource.ftl",
            "utf-8")
        request.setAttribute(cache_key, content)
        cache.put(cache_key, content)
예제 #2
0
 def genernate_resoure_content(self, webpart):
     cache_key = "sbj" + str(self.subject.subjectId) + "_" + str(webpart.getSubjectWebpartId()) + self.cacheKeyFix
     content = cache.get(cache_key)
     if content != None:
         request.setAttribute(cache_key, content)
         return
     
     map = HashMap()        
     qry = ResourceQuery(""" r.resourceId, r.title, r.href, r.createDate, r.fsize, r.downloadCount, 
     u.loginName, u.nickName, r.subjectId as subjectId, grad.gradeName, sc.name as scName """)
     qry.subjectId = self.metaSubjectId
     qry.gradeId = self.metaGradeId
     qry.FuzzyMatch = True
     if self.unitId != None and self.unitId != 0:
         qry.custormAndWhereClause = " r.approvedPathInfo LIKE '%/" + str(self.unitId) + "/%'"
     new_resource_list = qry.query_map(10)
     map.put("new_resource_list", new_resource_list)
     
     qry = ResourceQuery(""" r.resourceId, r.title, r.href, r.createDate, r.fsize, r.downloadCount, 
     u.loginName, u.nickName, msubj.msubjName, grad.gradeName, sc.name as scName """)
     qry.orderType = 4       # downloadCount DESC
     qry.subjectId = self.metaSubjectId
     qry.gradeId = self.metaGradeId
     qry.FuzzyMatch = True
     if self.unitId != None and self.unitId != 0:
         qry.custormAndWhereClause = " r.approvedPathInfo LIKE '%/" + str(self.unitId) + "/%'"
     hot_resource_list = qry.query_map(10)
     map.put("hot_resource_list", hot_resource_list)
     
     #hot_resource_list = self.viewcount_svc.getViewCountListShared(12,7,10,self.unit.unitPath,self.unit.unitDepth);
     #map.put("hot_resource_list", hot_resource_list)
     
     # �Ƽ���Դ
     qry = ResourceQuery(""" r.resourceId, r.title, r.href, r.createDate, r.fsize, r.downloadCount, 
     u.loginName, u.nickName, msubj.msubjName, grad.gradeName, sc.name as scName """)
     qry.rcmdState = True
     qry.subjectId = self.metaSubjectId
     qry.gradeId = self.metaGradeId
     qry.FuzzyMatch = True
     if self.unitId != None and self.unitId != 0:
         qry.custormAndWhereClause = " r.rcmdPathInfo LIKE '%/" + str(self.unitId) + "/%'"
     rcmd_resource_list = qry.query_map(10)
     map.put("rcmd_resource_list", rcmd_resource_list)    
    
     map.put("subject", self.subject)
     map.put("SubjectRootUrl", self.subjectRootUrl)
     map.put("webpart", webpart)
     map.put("unitId", self.unitId)
     content = self.templateProcessor.processTemplate(map, "/WEB-INF/subjectpage/" + self.templateName + "/resource.ftl", "utf-8")
     request.setAttribute(cache_key, content)
     cache.put(cache_key, content)
예제 #3
0
    def execute(self):
        self.userName = request.getAttribute("loginName")
        if self.userName == None or self.userName == '':
            response.getWriter().write(u"没有该用户。")
            return
        user = self.userService.getUserByLoginName(self.userName)
        if user == None:
            response.getWriter().write(u"不能加载当前用户。")
            return
        fc = FileCache()
        content = fc.getUserFileCacheContent(self.userName,
                                             "user_resources.html", 30)
        if content != "":
            response.getWriter().write(content)
            fc = None
            return
        qry = ResourceQuery(" r.createDate, r.resourceId, r.title, r.href")
        qry.userId = user.userId
        qry.orderType = 0
        resource_list = qry.query_map(10)
        templateProcessor = __spring__.getBean("templateProcessor")
        map = HashMap()
        map.put("resource_list", resource_list)
        map.put("UserSiteUrl", self.getUserSiteUrl())
        content = templateProcessor.processTemplate(
            map, "/WEB-INF/user/default/user_resources.ftl", "utf-8")

        fc.writeUserFileCacheContent(self.userName, "user_resources.html",
                                     content)
        response.getWriter().write(content)
        fc = None
예제 #4
0
 def get_new_resource_list(self):
     qry = ResourceQuery(
         """   r.createDate, r.resourceId, r.title, r.href, u.loginName, u.nickName, u.userId """
     )
     qry.subjectId = self.get_subjectId()
     new_resource_list = qry.query_map(11)
     request.setAttribute("new_resource_list", new_resource_list)
예제 #5
0
    def query_resource(self):
        qry = ResourceQuery(
            """ r.resourceId, r.title, r.href, r.fsize, r.createDate, 
          u.loginName, u.nickName, grad.gradeName, sc.name as scName """)
        pager = self.createPager()

        # 根据页面参数处理.
        type = self.params.getStringParam("type")
        if type == "rcmd":
            qry.rcmdState = True
        elif type == "hot":
            qry.orderType = ResourceQuery.ORDER_TYPE_DOWNLOADCOUNT_DESC
        elif type == "cmt":
            qry.orderType = ResourceQuery.ORDER_TYPE_COMMENTCOUNT_DESC
        else:
            type = "new"
        request.setAttribute("type", type)

        qry.subjectId = self.subject.subjectId
        qry.k = self.params.getStringParam("k")
        qry.sysCateId = self.params.getIntParamZeroAsNull("categoryId")

        # 查询数据.
        pager.totalRows = qry.count()
        resource_list = qry.query_map(pager)

        request.setAttribute("resource_list", resource_list)
        request.setAttribute("pager", pager)
예제 #6
0
    def recycle_list(self):
        # 构造查询.
        query = ResourceQuery(
            """ r.resourceId, r.title, r.shareMode, r.createDate, u.loginName, u.nickName, r.subjectId, r.gradeId, 
        r.href, r.downloadCount, r.commentCount, r.fsize, sc.name as sysCateName, subj.subjectName """
        )
        query.auditState = None
        query.delState = True  # 获得被删除的.
        query.shareMode = None

        query.subjectId = self.params.getIntParamZeroAsNull("su")
        request.setAttribute("su", query.subjectId)
        query.gradeId = self.params.getIntParamZeroAsNull("gradeId")
        request.setAttribute("gradeId", query.gradeId)
        query.sysCateId = self.params.getIntParamZeroAsNull("sc")
        request.setAttribute("sc", query.sysCateId)
        query.kk = self.params.getStringParam("k")
        request.setAttribute("k", query.kk)
        query.f = self.params.getStringParam("f")
        request.setAttribute("f", query.f)

        # 计算总量.
        pager = self.createPager()
        pager.totalRows = query.count()

        # 得到资源.
        resource_list = query.query_map(pager)

        request.setAttribute("pager", pager)
        request.setAttribute("resource_list", resource_list)
        self.putSubjectList()
        self.putGradeList()
        self.putResourceCategoryTree()

        return self.RECYCLE_LIST
예제 #7
0
 def get_resource_querylist(self):
     qry = ResourceQuery(
         " r.resourceId, r.href, r.title, r.fsize, r.createDate,r.auditState "
     )
     resId = self.params.getStringParam("id")
     qry.resourceIds = resId
     qry.auditState = None
     resource_list = qry.query_map()
     request.setAttribute("resource_list", resource_list)
예제 #8
0
 def get_rcmd_resource_list(self):
     qry = ResourceQuery(
         """ r.createDate, r.resourceId, r.href, r.title, u.loginName, u.nickName, u.trueName,u.userId """
     )
     qry.subjectId = self.get_current_subjectId()
     qry.gradeId = self.get_current_gradeId()
     qry.rcmdState = True
     rcmd_resource_list = qry.query_map(11)
     request.setAttribute("rcmd_resource_list", rcmd_resource_list)
예제 #9
0
 def get_download_resource_list(self):
     qry = ResourceQuery(
         """ r.resourceId, r.href, r.title, r.downloadCount """)
     qry.subjectId = self.subject.metaSubject.msubjId
     qry.gradeId = self.subject.metaGrade.gradeId
     qry.FuzzyMatch = True
     qry.orderType = 4
     download_resource_list = qry.query_map(20)
     request.setAttribute("download_resource_list", download_resource_list)
예제 #10
0
    def get_list(self):
        query = ResourceQuery(
            """ r.resourceId, r.title, r.shareMode, r.createDate, r.href, r.subjectId, r.gradeId, r.rcmdPathInfo,
            r.delState, r.unitPathInfo, r.approvedPathInfo, r.downloadCount, r.commentCount, r.fsize, r.auditState, r.recommendState, r.tags, r.addIp, r.pushState,
            u.userId, u.loginName, u.nickName, sc.name as sysCateName, subj.subjectName """
        )

        multiPushState = self.params.safeGetStringParam("multiPushState")
        recommendState = self.params.safeGetStringParam("recommendState")
        auditState = self.params.safeGetStringParam("auditState")

        query.shareMode = None
        query.unitId = None  #不使用该字段

        custormAndWhereClause = "r.unitPathInfo LIKE '%/" + str(
            self.unit.unitId) + "/%' And r.unitId != " + str(
                self.unit.unitId) + " And"
        if multiPushState == "1":
            custormAndWhereClause += " r.unitPathInfo LIKE '%/" + str(
                self.unit.parentId) + "/%' And"
        elif multiPushState == "0":
            custormAndWhereClause += " r.unitPathInfo NOT LIKE '%/" + str(
                self.unit.parentId) + "/%' And"

        if recommendState == "1":
            custormAndWhereClause += " r.rcmdPathInfo LIKE '%/" + str(
                self.unit.unitId) + "/%' And"
        elif recommendState == "0":
            custormAndWhereClause += " (r.rcmdPathInfo Is Null or r.rcmdPathInfo Not LIKE '%/" + str(
                self.unit.unitId) + "/%') And"

        if auditState == "0":
            custormAndWhereClause += " r.approvedPathInfo LIKE '%/" + str(
                self.unit.unitId) + "/%' And"
        elif auditState == "1":
            custormAndWhereClause += " (r.approvedPathInfo Is Null or r.approvedPathInfo NOT LIKE '%/" + str(
                self.unit.unitId) + "/%') And"

        if custormAndWhereClause[len(custormAndWhereClause) - 3:] == "And":
            custormAndWhereClause = custormAndWhereClause[
                0:len(custormAndWhereClause) - 3]

        query.custormAndWhereClause = custormAndWhereClause

        # 计算总量.
        pager = self.createPager()
        pager.pageSize = 20
        pager.totalRows = query.count()

        # 得到资源.
        resource_list = query.query_map(pager)

        request.setAttribute("pager", pager)
        request.setAttribute("resource_list", resource_list)
        request.setAttribute("multiPushState", multiPushState)
        request.setAttribute("recommendState", recommendState)
        request.setAttribute("auditState", auditState)
예제 #11
0
    def get_download_resource_list(self):
        qry = ResourceQuery(
            """ r.resourceId, r.href, r.title, r.downloadCount """)
        qry.subjectId = self.params.getIntParamZeroAsNull("subjectId")
        qry.sysCateId = self.params.getIntParamZeroAsNull("categoryId")
        qry.k = self.params.getStringParam("k")

        qry.orderType = 4
        download_resource_list = qry.query_map(20)
        request.setAttribute("download_resource_list", download_resource_list)
예제 #12
0
파일: index.py 프로젝트: yxxcrtd/jitar2.0
 def get_new_resource_list(self):
     cache_key = "new_resource_list"
     new_resource_list = cache.get(cache_key)
     if new_resource_list == None:
         qry = ResourceQuery(
             """ r.userId, r.resourceId, r.title, r.href, r.createDate, r.fsize, r.downloadCount, 
             u.loginName, u.trueName, r.createDate """)
         # qry.unit = self.unit
         qry.unitId = None
         qry.custormAndWhereClause = " r.approvedPathInfo Like '%/" + str(
             self.unit.unitId) + "/%' "
         new_resource_list = qry.query_map(10)
         cache.put(cache_key, new_resource_list)
     request.setAttribute("new_resource_list", new_resource_list)
예제 #13
0
 def show_list(self):
     qry = ResourceQuery(
         """ r.resourceId,r.title,r.userId,r.pushState,r.unitId,r.href,r.pushUserId """
     )
     qry.pushState = 2  # 待推送
     pager = self.params.createPager()
     pager.itemName = u"资源"
     pager.itemUnit = u"个"
     pager.pageSize = 25
     pager.totalRows = qry.count()
     resource_list = qry.query_map(pager)
     request.setAttribute("resource_list", resource_list)
     request.setAttribute("pager", pager)
     return "/WEB-INF/push/admin_push_resource_list.ftl"
예제 #14
0
    def get_resource_list(self):
        qry = ResourceQuery(
            " r.resourceId, r.href, r.title, r.fsize, r.createDate, u.loginName, u.nickName, r.subjectId as subjectId, grad.gradeName, sc.name as scName "
        )
        type = self.params.getStringParam("type")

        if type == None or type == "": type = "new"
        list_type = ""
        if type == "hot":
            qry.orderType = ResourceQuery.ORDER_TYPE_VIEWCOUNT_DESC
            qry.custormAndWhereClause = " r.approvedPathInfo Like '%/" + str(
                self.unit.unitId) + "/%' "
            list_type = u"最高人气"
        elif type == "rcmd":
            #qry.rcmdState = True
            qry.custormAndWhereClause = " r.rcmdPathInfo Like '%/" + str(
                self.unit.unitId
            ) + "/%' And r.approvedPathInfo Like '%/" + str(
                self.unit.unitId) + "/%' "
            list_type = u"编辑推荐"
        elif type == "cmt":
            qry.orderType = ResourceQuery.ORDER_TYPE_COMMENTCOUNT_DESC
            qry.custormAndWhereClause = " r.approvedPathInfo Like '%/" + str(
                self.unit.unitId) + "/%' "
            list_type = u"评论最多"
        else:
            type = "new"
            qry.custormAndWhereClause = " r.approvedPathInfo Like '%/" + str(
                self.unit.unitId) + "/%' "
            list_type = u"最新资源"
        request.setAttribute("type", type)
        request.setAttribute("list_type", list_type)

        qry.gradelevel = self.params.getIntParamZeroAsNull("level")
        qry.subjectId = self.params.getIntParamZeroAsNull("subjectId")
        qry.sysCateId = self.params.getIntParamZeroAsNull("categoryId")
        qry.gradeId = self.params.getIntParamZeroAsNull("gradeId")
        qry.k = self.params.getStringParam("k")

        pager = self.createPager()

        pager.totalRows = qry.count()
        resource_list = qry.query_map(pager)

        request.setAttribute("resource_list", resource_list)
        request.setAttribute("pager", pager)
        request.setAttribute("subjectId", qry.subjectId)
        request.setAttribute("categoryId", qry.sysCateId)
예제 #15
0
파일: index.py 프로젝트: yxxcrtd/jitar2.0
 def get_hot_resource_list(self):
     cache_key = "hot_resource_list"
     hot_resource_list = cache.get(cache_key)
     # hot_resource_list=None
     if hot_resource_list == None:
         qry = ResourceQuery(
             """ r.userId, r.resourceId, r.title, r.href, r.createDate, r.fsize, r.downloadCount, 
             u.loginName, u.trueName, msubj.msubjName, grad.gradeName, sc.name as scName """
         )
         # qry.unit = self.unit
         qry.unitId = None
         qry.custormAndWhereClause = " r.approvedPathInfo Like '%/" + str(
             self.unit.unitId) + "/%' "
         qry.orderType = 4  # downloadCount DESC
         hot_resource_list = qry.query_map(10)
         cache.put(cache_key, hot_resource_list)
     request.setAttribute("hot_resource_list", hot_resource_list)
예제 #16
0
파일: index.py 프로젝트: yxxcrtd/jitar2.0
 def get_rcmd_resource_list(self):
     cache_key = "rcmd_resource_list"
     rcmd_resource_list = cache.get(cache_key)
     if rcmd_resource_list == None:
         qry = ResourceQuery(
             " r.userId, r.resourceId, r.title, r.href, r.createDate, r.fsize, r.downloadCount, r.subjectId as subjectId, grad.gradeName, sc.name as scName "
         )
         # qry.unit = self.unit
         qry.unitId = None
         # qry.rcmdState = True
         qry.custormAndWhereClause = " r.rcmdPathInfo Like '%/" + str(
             self.unit.unitId
         ) + "/%' and r.approvedPathInfo Like '%/" + str(
             self.unit.unitId) + "/%' "
         rcmd_resource_list = qry.query_map(10)
         cache.put(cache_key, rcmd_resource_list)
     request.setAttribute("rcmd_resource_list", rcmd_resource_list)
예제 #17
0
    def query_resource(self):
        qry = ResourceQuery(
            """ r.resourceId, r.title, r.href, r.fsize, r.createDate, 
              u.loginName, u.nickName, grad.gradeName, sc.name as scName """)
        pager = self.createPager()
        if self.unitId != None and self.unitId != 0:
            qry.custormAndWhereClause = " r.approvedPathInfo LIKE '%/" + str(
                self.unitId) + "/%'"
        # 根据页面参数处理.
        type = self.params.getStringParam("type")
        if type == "rcmd":
            qry.rcmdState = True
            if self.unitId != None and self.unitId != 0:
                # 覆盖掉前面的设置
                qry.custormAndWhereClause = " r.rcmdPathInfo LIKE '%/" + str(
                    self.unitId) + "/%'"
        elif type == "hot":
            qry.orderType = ResourceQuery.ORDER_TYPE_DOWNLOADCOUNT_DESC
        elif type == "cmt":
            qry.orderType = ResourceQuery.ORDER_TYPE_COMMENTCOUNT_DESC
        else:
            type = "new"

        request.setAttribute("type", type)
        qry.subjectId = self.get_current_subjectId()

        #qry.gradeId = self.get_current_gradeId()
        qry.gradeId = self.levelGradeId
        qry.gradelevel = self.params.getIntParamZeroAsNull("level")
        qry.FuzzyMatch = True

        qry.k = self.params.getStringParam("k")
        qry.sysCateId = self.params.getIntParamZeroAsNull("categoryId")

        # 查询数据.
        pager.totalRows = qry.count()
        resource_list = qry.query_map(pager)

        request.setAttribute("resource_list", resource_list)
        request.setAttribute("pager", pager)
예제 #18
0
  def resource(self):
      qry = ResourceQuery(""" r.resourceId, r.title, r.createDate, u.trueName,
                            u.loginName, u.userIcon, subj.subjectName,
                           r.summary, r.lastModified                           
                            """)
      userId = request.getParameter("userId")      
      if(request.getParameter("userId") != None):
          qry.userId = int(userId)
          request.setAttribute("showType", "user")
          
      qry.orderType = 0
      result = qry.query_map(20)
      
      #print "result = ", result
      #return
      for a in result:
          str = a['lastModified']
          str = CommonUtil.rssDateFormat(str)
          a['lastModifiedString'] = str         

                
      request.setAttribute("resource_list", result)
      response.setContentType("text/xml; charset=UTF-8")
      return "/WEB-INF/ftl/site_rss_resource.ftl"
예제 #19
0
    def execute(self):
        q = request.getQueryString()
        response.sendRedirect(request.getContextPath() +
                              "/showResource.action?" + q)

        param = ParamUtil(request)
        resourceId = param.getIntParam("resourceId")
        shareMode = param.getIntParam("shareMode")
        if resourceId == None or resourceId == "":
            request.setAttribute("error", u"无效的标识。")
            return "/WEB-INF/ftl/show_resource.ftl"
        self.res_svc = __jitar__.getResourceService()

        # 得到的信息不全啊
        resource = self.res_svc.getResource(resourceId)
        if resource == None:
            request.setAttribute("error", u"无法加载该资源。")
            return "/WEB-INF/ftl/show_resource.ftl"

        punshScore = self.pun_svc.getUPunishScore(
            ObjectType.OBJECT_TYPE_RESOURCE.getTypeId(), resourceId)
        if punshScore != None:
            if punshScore.getScore() < 0:
                request.setAttribute("scoreCreateUserId",
                                     punshScore.getCreateUserId())
                request.setAttribute("scoreCreateUserName",
                                     punshScore.getCreateUserName())
                request.setAttribute("score", -1 * punshScore.getScore())
                request.setAttribute("scoreReason", punshScore.getReason())
                request.setAttribute("scoreDate", punshScore.getPunishDate())
                request.setAttribute("scoreObjId", punshScore.getObjId())
                request.setAttribute("scoreObjTitle", punshScore.getObjTitle())

        qry = ResourceQuery(
            """ r.resourceId, r.title, r.href, r.createDate, r.fsize, r.downloadCount, 
                                r.author, r.publisher, r.summary, u.loginName, r.subjectId, 
                                grad.gradeName, sc.name as scName, r.shareMode,r.userId,r.recommendState """
        )

        # 如果是管理者或者作者自己,则可以浏览
        if self.loginUser != None:
            accessControlService = __spring__.getBean("accessControlService")
            isAdmin = False
            adminList = accessControlService.getAllAccessControlByUser(
                self.loginUser)
            if len(adminList) > 0:
                isAdmin = True

            if self.loginUser.userId == resource.userId or accessControlService.isSystemAdmin(
                    self.loginUser) or isAdmin == True:
                qry.auditState = None
                qry.delState = None
            else:
                if resource.auditState == True or resource.delState == True:
                    request.setAttribute("error", u"该资源未审核或者待删除。")
                    return "/WEB-INF/ftl/show_resource.ftl"
        else:
            if resource.auditState == True or resource.delState == True:
                request.setAttribute("error", u"该资源未审核或者待删除。")
                return "/WEB-INF/ftl/show_resource.ftl"

        qry.resourceId = resource.resourceId
        qry.shareMode = resource.shareMode
        new_resource_list = qry.query_map(1)
        # print "====", new_resource_list

        if (len(new_resource_list) > 0):
            request.setAttribute("resource", new_resource_list[0])
        else:
            return
        res = new_resource_list[0]
        query = AdminCommentQuery(
            " cmt.id, cmt.title, cmt.content, cmt.audit, cmt.createDate, cmt.userId, cmt.userName, cmt.star, cmt.objType, cmt.objId, u.userIcon, u.loginName, u.trueName "
        )
        query.objType = 12
        query.objId = resource.resourceId
        query.audit = 1
        # 调用分页函数.
        pager = self.createPager()
        pager.totalRows = query.count()
        commentList = query.query_map(pager)
        request.setAttribute("comment_list", commentList)
        request.setAttribute("pager", pager)

        conf = JitarContext.getCurrentJitarContext().getConfigService(
        ).getConfigure()
        largefileupload = conf.getValue("resource.download")
        if (largefileupload == 1):
            request.setAttribute("resourcedowload", "true")
        else:
            if self.loginUser == None:
                if self.getMashupUserCookie() == "":
                    request.setAttribute("resourcedowload", "false")
                else:
                    request.setAttribute("resourcedowload", "true")
            else:
                request.setAttribute("resourcedowload", "true")

        response.setContentType("text/html; charset=UTF-8")

        # 增加资源的访问量
        self.res_svc.increaseViewCount(resourceId)
        if self.getImpersonateUser() != None:
            request.setAttribute("resourcedowload", "true")
        filename = res["href"]
        if filename != None and filename != "":
            filename = filename.lower()
            canPreview = False
            if filename.endswith(".jpg") or filename.endswith(
                    ".gif") or filename.endswith(".png") or filename.endswith(
                        ".txt"):
                canPreview = True
            elif filename.endswith(".doc") or filename.endswith(
                    ".docx"
            ) or filename.endswith(".swf") or filename.endswith(
                    ".pdf"
            ):  # or filename.endswith(".xls") or filename.endswith(".xlsx") or filename.endswith(".ppt") or filename.endswith(".pptx"):
                PDF2SWFPath = request.getSession().getServletContext(
                ).getInitParameter("pdf2swfPath")
                if PDF2SWFPath != None and PDF2SWFPath != "":
                    canPreview = True
                prepareCourseFileServer = request.getSession(
                ).getServletContext().getInitParameter(
                    "PrepareCourseFileServer")
                if prepareCourseFileServer != None and prepareCourseFileServer != "":
                    canPreview = False
            if canPreview:
                request.setAttribute("resourceId", resource.resourceId)
                request.setAttribute("canPreview", "true")

        return "/WEB-INF/ftl/show_resource.ftl"
예제 #20
0
    def list(self):
        # 构造查询.
        query = ResourceQuery(
            """ r.resourceId, r.title, r.shareMode, r.createDate, r.href, r.subjectId, r.gradeId, 
            r.downloadCount, r.commentCount, r.fsize, r.auditState, r.recommendState, r.tags, r.addIp, r.pushState,
            u.userId, u.loginName, u.nickName, sc.name as sysCateName, subj.subjectName """
        )

        query.auditState = None
        query.delState = False  # 过滤被删除了的.

        recommendState = self.params.safeGetStringParam("recommendState")
        if recommendState == "1":
            query.rcmdState = 1
        elif recommendState == "0":
            query.rcmdState = 0

        auditState = self.params.safeGetStringParam("auditState")
        if auditState == "1":
            query.auditState = 1
        elif auditState == "0":
            query.auditState = 0

        query.shareMode = None
        query.unitId = self.unit.unitId

        # 根据参数设置过滤条件.
        type = self.params.getStringParam("type")
        request.setAttribute("type", type)
        if type == "rcmd":  # 推荐.
            query.rcmdState = True
        elif type == "unaudit":  # 待审核.
            query.auditState = Resource.AUDIT_STATE_WAIT_AUDIT

        query.subjectId = self.params.getIntParamZeroAsNull("su")
        request.setAttribute("su", query.subjectId)
        query.gradeId = self.params.getIntParamZeroAsNull("gradeId")
        request.setAttribute("gradeId", query.gradeId)
        query.sysCateId = self.params.getIntParamZeroAsNull("sc")
        request.setAttribute("sc", query.sysCateId)
        query.kk = self.params.getStringParam("k")
        request.setAttribute("k", query.kk)
        query.f = self.params.getStringParam("f")
        request.setAttribute("f", query.f)

        # 计算总量.
        pager = self.createPager()
        pager.pageSize = 10
        pager.totalRows = query.count()

        # 得到资源.
        resource_list = query.query_map(pager)

        request.setAttribute("pager", pager)
        request.setAttribute("resource_list", resource_list)
        self.putSubjectList()
        self.putGradeList()
        self.putResourceCategoryTree()

        request.setAttribute("recommendState", recommendState)
        request.setAttribute("auditState", auditState)
        return "/WEB-INF/unitsmanage/unit_owner_resource.ftl"
예제 #21
0
    def get_request(self):
        query = ResourceQuery(
            """ r.resourceId, r.title, r.shareMode, r.createDate, r.href, r.subjectId, r.gradeId, r.rcmdPathInfo,r.unitId,
            r.delState, r.unitPathInfo, r.approvedPathInfo, r.downloadCount, r.commentCount, r.fsize, r.auditState, r.recommendState, r.tags, r.addIp, 
            u.userId, u.loginName, u.nickName, sc.name as sysCateName """)

        query.unitId = None
        query.auditState = None
        query.delState = None

        multiPushState = self.params.safeGetStringParam("multiPushState")
        recommendState = self.params.safeGetStringParam("recommendState")
        auditState = self.params.safeGetStringParam("auditState")
        delState = self.params.safeGetStringParam("delState")

        custormAndWhereClause = "r.orginPathInfo LIKE '%/" + str(
            self.unit.unitId) + "/%' And r.unitId <> " + str(
                self.unit.unitId) + " And"

        # 得到全部的下级单位
        unitList = self.unitService.getDownUnitList(self.unit)

        if recommendState == "1":
            strRcmd = ""
            for ut in unitList:
                strRcmd = strRcmd + " r.rcmdPathInfo LIKE '%/" + str(
                    ut.unitId) + "/%' or"
            if strRcmd != "":
                strRcmd = strRcmd[0:len(strRcmd) - 2]
                custormAndWhereClause += " (" + strRcmd + ") And"
        elif recommendState == "0":
            strRcmd = ""
            for ut in unitList:
                strRcmd = strRcmd + " r.rcmdPathInfo Not LIKE '%/" + str(
                    ut.unitId) + "/%' And"
            if strRcmd != "":
                strRcmd = strRcmd[0:len(strRcmd) - 3]
                custormAndWhereClause += " (r.rcmdPathInfo Is Null or (" + strRcmd + ")) And"

        if auditState == "0":
            strApprove = ""
            for ut in unitList:
                strApprove = strApprove + " r.approvedPathInfo LIKE '%/" + str(
                    ut.unitId) + "/%' or"
            if strApprove != "":
                strApprove = strApprove[0:len(strApprove) - 2]
                custormAndWhereClause += "(" + strApprove + ") And"
        elif auditState == "1":
            strApprove = ""
            for ut in unitList:
                strApprove = strApprove + " r.approvedPathInfo NOT LIKE '%/" + str(
                    ut.unitId) + "/%' And"
            if strApprove != "":
                strApprove = strApprove[0:len(strApprove) - 3]
                custormAndWhereClause += " (r.approvedPathInfo Is Null or (" + strApprove + ")) And"
        """
        if auditState == "0":
            custormAndWhereClause += " r.approvedPathInfo LIKE '%/" + str(self.unit.unitId) + "/%' And"
        elif auditState == "1":
            custormAndWhereClause += " (r.approvedPathInfo Is NUll or r.approvedPathInfo NOT LIKE '%/" + str(self.unit.unitId) + "/%') And"
        
        if multiPushState == "1":
            custormAndWhereClause += " r.unitPathInfo LIKE '%/" + str(self.unit.parentId) + "/%' And"
        elif multiPushState == "0":
            custormAndWhereClause += " r.unitPathInfo NOT LIKE '%/" + str(self.unit.parentId) + "/%' And"
        
        if recommendState == "1":
            custormAndWhereClause += " r.rcmdPathInfo LIKE '%/" + str(self.unit.unitId) + "/%' And"
        elif recommendState == "0":
            custormAndWhereClause += " (r.rcmdPathInfo Is NULL or r.rcmdPathInfo NOT LIKE '%/" + str(self.unit.unitId) + "/%') And"
        """

        if delState == "0":
            query.delState = False
        elif delState == "1":
            query.delState = True

        if custormAndWhereClause[len(custormAndWhereClause) - 3:] == "And":
            custormAndWhereClause = custormAndWhereClause[
                0:len(custormAndWhereClause) - 3]
        query.custormAndWhereClause = custormAndWhereClause
        #print custormAndWhereClause

        # 计算总量.
        pager = self.createPager()
        pager.pageSize = 20
        pager.totalRows = query.count()

        # 得到资源.
        resource_list = query.query_map(pager)

        request.setAttribute("pager", pager)
        request.setAttribute("resource_list", resource_list)
        #self.putSubjectList()
        #self.putGradeList()
        #self.putResourceCategoryTree()

        request.setAttribute("delState", delState)
        request.setAttribute("multiPushState", multiPushState)
        request.setAttribute("recommendState", recommendState)
        request.setAttribute("auditState", auditState)
        #self.putSubjectList()
        #self.putGradeList()
        self.putResourceCategoryTree()
예제 #22
0
    def execute(self):
        writer = response.getWriter()

        self.params = ParamUtil(request)
        loginName = request.getAttribute("loginName")
        if (loginName == None or loginName == ''):
            writer.write("没有该用户。")
            return

        # 加载当前用户对象.
        user = __jitar__.userService.getUserByLoginName(loginName)
        request.setAttribute("user", user)
        if self.canVisitUser(user) == False:
            return self.ACCESS_ERROR

        # loginUser 对象来自基类 BaseAdminAction .
        request.setAttribute("loginUser", self.loginUser)

        # 创建分页对象
        pager = self.params.createPager()
        pager.setPageSize(20)
        qry = ResourceQuery(
            """ r.resourceId, r.title, r.createDate                              
                            """)
        qry.userId = user.userId
        #if userStapleId != 0 :
        #    qry.userStapleId = userStapleId

        #print "userStapleId = ", userStapleId
        pager.totalRows = qry.count()
        pager.itemName = u"资源"
        pager.itemUnit = u"个"
        qry.orderType = 0

        result = qry.query_map(pager)
        request.setAttribute("user_resource_list", result)
        request.setAttribute("pager", pager)

        hql = """SELECT new Map(p.skin as skin)
             FROM Page p 
             WHERE p.name = 'index' and p.objId = :userId and p.objType = 1
             """
        pageSkin = Command(hql).setInteger("userId", user.userId).first()

        # 构造页面数据,由于页面不是在数据库存在的,这里的数据是虚拟数据.
        #pages : [{id: ${page.pageId}, title: '${user.blogName!?js_string}', layoutId: ${page.layoutId!0} }],
        page = {
            "pageId": 0,
            "layoutId": 2,  # 固定是布局2
            "isSystemPage": "true",
            "owner": "user",
            "title": "",
            "skin": pageSkin["skin"]
        }
        request.setAttribute("page", page)

        # 构造widgets .
        widgets = [{
            "id": "1",
            "pageId": 0,
            "columnIndex": 1,
            "title": u"个人档案",
            "module": "profile",
            "ico": "",
            "data": ""
        }, {
            "id": "2",
            "pageId": 0,
            "columnIndex": 1,
            "title": u"资源分类",
            "module": "user_rcate",
            "ico": "",
            "data": ""
        }, {
            "id": "placerholder1",
            "pageId": 0,
            "columnIndex": 2,
            "title": "",
            "module": "placeholder",
            "ico": "",
            "data": ""
        }]

        request.setAttribute("widgets", widgets)
        request.setAttribute("widget_list", widgets)

        response.setContentType("text/html; charset=UTF-8")
        return "/WEB-INF/user/default/user_resource_list.ftl"