Example #1
0
    def execute(self):
        self.params = ParamUtil(request)
        showCount = self.params.safeGetIntParam("count")
        contentSpaceId = self.params.safeGetIntParam("contentSpaceId")
        showType = self.params.safeGetIntParam("showType")
        unitId = self.params.safeGetIntParam("unitId")
        if showCount == 0:
            showCount = 8
        if showType == 0:
            showType = 1
        if contentSpaceId == 0 or unitId == 0:
            response.getWriter().println(u"标识不足。")
            return

        self.unit = self.getUnit()
        if self.unit == None:
            response.getWriter().println(u"不能加载机构信息。")
            return

        unitTemplateName = "template1"
        if self.unit.templateName != None and self.unit.templateName != "":
            unitTemplateName = self.unit.templateName
        qry = ContentSpaceArticleQuery(
            """ csa.title,csa.contentSpaceArticleId,csa.createDate,csa.pictureUrl,csa.viewCount,cs.contentSpaceId """
        )
        qry.contentSpaceId = contentSpaceId
        article_list = qry.query_map(showCount)
        request.setAttribute("article_list", article_list)
        request.setAttribute("showType", showType)
        request.setAttribute("unit", self.unit)
        return "/WEB-INF/unitspage/" + unitTemplateName + "/get_unit_contentspace_article.ftl"
    def execute(self):
        self.params = ParamUtil(request)
        showCount = self.params.safeGetIntParam("count")
        contentSpaceId = self.params.safeGetIntParam("contentSpaceId")
        textLength = self.params.safeGetIntParam("textLength")
        showType = self.params.safeGetIntParam("showType")
        if textLength == 0:
            textLength = 12
        if showCount == 0:
            showCount = 8
        if showType == 0:
            showType = 1

        qry = ContentSpaceArticleQuery(
            " csa.title,csa.contentSpaceArticleId,csa.createDate,csa.pictureUrl,csa.viewCount,cs.contentSpaceId "
        )
        qry.contentSpaceId = contentSpaceId
        if showType == 1 or showType == 3:
            article_list = qry.query_map(showCount)
            request.setAttribute("article_list", article_list)
            #return "/WEB-INF/subjectpage/" + subjectTemplateName + "/get_contentspace_article.ftl"
            #print "article_list=",article_list
        if showType == 3:
            qry.hasPicture = True
            picture_article_list = qry.query_map(4)
            request.setAttribute("picture_article_list", picture_article_list)

        if showType == 2:
            qry.hasPicture = True
            picture_article_list = qry.query_map(showCount)
            request.setAttribute("picture_article_list", picture_article_list)

        request.setAttribute("textLength", textLength)
        request.setAttribute("showType", showType)
        return "/WEB-INF/ftl2/index/get_contentspace_article.ftl"
 def execute(self):
     self.params = ParamUtil(request)
     showCount = self.params.safeGetIntParam("count")
     contentSpaceId = self.params.safeGetIntParam("contentSpaceId")
     showType = self.params.safeGetIntParam("showType")   
     if showCount == 0:
         showCount = 8
     if showType == 0:
         showType = 1
     if self.params.existParam("subject") == True:
         subjectTemplateName = "template1"
         if self.subject.templateName != None:
             subjectTemplateName = self.subject.templateName
         qry = ContentSpaceArticleQuery(""" csa.title,csa.contentSpaceArticleId,csa.createDate,csa.pictureUrl,csa.viewCount,cs.contentSpaceId """)
         qry.contentSpaceId = contentSpaceId
         article_list = qry.query_map(showCount)
         request.setAttribute("article_list", article_list)
         request.setAttribute("showType", showType)           
         return "/WEB-INF/subjectpage/" + subjectTemplateName + "/get_contentspace_article.ftl"
     else:
         response.getWriter().println(u"无效的请求。")
Example #4
0
    def execute(self):
        site_config = SiteConfig()
        site_config.get_config()

        # 得到分页
        param = ParamUtil(request)
        type = param.safeGetIntParam("type")

        pager = param.createPager()
        pager.itemName = u"文章"
        pager.itemUnit = u"篇"
        pager.pageSize = 30

        if type == 2:
            qry = ContentSpaceArticleQuery(
                """ cs.spaceName, csa.title, csa.createDate, csa.viewCount, csa.contentSpaceArticleId """
            )
            qry.ownerType = 0
            qry.ownerId = 0
            qry.contentSpaceId = param.safeGetIntParam("categoryId")
            pager.totalRows = qry.count()
            article_list = qry.query_map(pager)
            request.setAttribute("article_list", article_list)
            request.setAttribute("pager", pager)
            request.setAttribute("Page_Title",
                                 param.safeGetStringParam("title"))
            return "/WEB-INF/ftl/mengv1/index/show_custorm_contentspace_article.ftl"
        else:
            qry = ArticleQuery(
                """ a.articleId, a.title, a.createDate, a.viewCount, a.commentCount, a.userId,
                                  a.recommendState, a.typeState, u.loginName, u.nickName, u.trueName """
            )
            pager.totalRows = qry.count()
            article_list = qry.query_map(pager)
            request.setAttribute("article_list", article_list)
            request.setAttribute("pager", pager)
            request.setAttribute("Page_Title",
                                 param.safeGetStringParam("title"))
            return "/WEB-INF/ftl/mengv1/index/show_custorm_article.ftl"
Example #5
0
    def execute(self):
        self.params = ParamUtil(request)
        contentSpaceId = self.params.safeGetIntParam("contentSpaceId")

        self.unit = self.getUnit()
        if self.unit == None:
            self.addActionError(u"不能加载机构信息。")
            return self.ERROR

        if self.unit.delState == True:
            self.addActionError(u"您所访问的机构已经被删除!")
            return self.ERROR

        partType = self.params.safeGetIntParam("partType")

        self.templateName = "template1"
        if self.unit.templateName != None and self.unit.templateName != "":
            self.templateName = self.unit.templateName

        if partType == 2:
            qry = ContentSpaceArticleQuery(
                """ csa.title,csa.contentSpaceArticleId,csa.createDate,csa.pictureUrl,csa.viewCount,cs.contentSpaceId  """
            )
            qry.contentSpaceId = self.params.safeGetIntParam("categoryId")
        else:
            qry = ArticleQuery(
                """ a.articleId, a.title, a.createDate, a.viewCount, a.commentCount, a.userId,
                                  a.recommendState, a.typeState, u.loginName, u.nickName, u.trueName """
            )
            qry.custormAndWhereClause = "a.approvedPathInfo LIKE '%/" + str(
                self.unit.unitId) + "/%'"
            qry.sysCateId = self.params.getIntParamZeroAsNull("categoryId")

        strError = ""
        pager = self.createPager()
        pager.totalRows = qry.count()
        article_list = qry.query_map(pager)
        request.setAttribute("article_list", article_list)
        request.setAttribute("pager", pager)
        request.setAttribute("partType", partType)
        request.setAttribute("unit", self.unit)
        pt = self.params.safeGetStringParam("title")
        request.setAttribute("Page_Title", pt)

        return "/WEB-INF/unitspage/" + self.templateName + "/show_unit_custorm_article.ftl"
Example #6
0
    def execute(self):
        if self.subject == None:
            self.addActionError(u"无法加载指定的学科。")
            return self.ERROR

        self.templateName = "template1"
        partType = self.params.safeGetIntParam("partType")
        if self.subject.templateName != None:
            self.templateName = self.subject.templateName
        if partType == 2:
            qry = ContentSpaceArticleQuery(
                """ csa.title,csa.contentSpaceArticleId,csa.createDate,csa.pictureUrl,csa.viewCount,cs.contentSpaceId  """
            )
            qry.contentSpaceId = self.params.safeGetIntParam("categoryId")
        else:
            unitId = self.params.safeGetIntParam("unitId")
            if unitId == None:
                unitId = 0
            qry = ArticleQuery(
                """ a.articleId, a.title, a.createDate, a.viewCount, a.commentCount, a.userId,
                                  a.recommendState, a.typeState, u.loginName, u.nickName, u.trueName """
            )
            qry.subjectId = self.subject.metaSubject.msubjId
            qry.gradeId = self.subject.metaGrade.gradeId
            qry.FuzzyMatch = True
            qry.sysCateId = self.params.getIntParamZeroAsNull("categoryId")
            qry.custormAndWhereClause = "a.approvedPathInfo LIKE '%/" + str(
                unitId) + "/%'"
            request.setAttribute("unitId", unitId)

        pager = self.createPager()
        pager.totalRows = qry.count()
        article_list = qry.query_map(pager)
        request.setAttribute("article_list", article_list)
        request.setAttribute("pager", pager)
        request.setAttribute("partType", partType)
        request.setAttribute("subject", self.subject)
        request.setAttribute("Page_Title",
                             self.params.safeGetStringParam("title"))

        return "/WEB-INF/subjectpage/" + self.templateName + "/show_custorm_article.ftl"