1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
##############################################################################
#
# This software is released under the Zope Public License (ZPL) Version 1.0
#
# Copyright (c) Digital Creations. All rights reserved.
# Portions Copyright (c) 1999 by Butch Landingin.
# Portions Copyright (c) 2000-2001 by Chris Withers.
#
##############################################################################
__version__='$Revision: 1.17 $'[11:-2]
import Globals
from time import time
from Utility import tagRegex
from SquishPermissions import View
from Posting import Posting
from string import join
from AccessControl import ClassSecurityInfo
class Article(Posting):
""" """
security = ClassSecurityInfo()
meta_type ='Article'
icon ='misc_/Squishdot/posting_img'
_fields =['title','author','body','email','subject','summary','dept']
security.declarePrivate('textToSearch')
def textToSearch(self):
# returns the text to search for a ZCatalog
text=''
try:
for line in self.summary:
# strip out HTML and append a newline to each line.
text = text+tagRegex.sub("",line)+'\n'
except TypeError:
pass
try:
for line in self.body:
# strip out HTML and append a newline to each line.
text = text+tagRegex.sub("",line)+'\n'
except TypeError:
pass
return text
security.declareProtected(View, 'prev_item')
def prev_item(self):
#""" return previous id in the item list"""
parent = self.site()[0]
currtime = int(time())
rlist = list(parent.id_list(currtime))
currpos = 0
try:
currpos = rlist.index(int(self.id))
except:
currpos = -1
if (currpos == 0) or (currpos < 0):
return None
else:
previd = rlist[currpos - 1]
obj = self.data[previd]
return (obj.__of__(self),)
security.declareProtected(View, 'next_item')
def next_item(self):
#""" return next id in the item list """
parent = self.site()[0]
currtime = int(time())
rlist = list(parent.id_list(currtime))
currpos = 0
try:
currpos = rlist.index(int(self.id))
except:
currpos = -1
lastpos = len(rlist) - 1
if (currpos == lastpos) or (currpos < 0):
return None
else:
nextid = rlist[currpos + 1]
obj = self.data[nextid]
return (obj.__of__(self),)
security.declareProtected(View, 'showSummary')
def showSummary(self):
# Used to display the summary of the article with the appropriate formatting
return self.render(self.summary,self.encoding)
# Return the plain text body of a posting suitable for mailing...
security.declareProtected(View, 'plain_text')
def plain_text(self):
if self.encoding == 'Plain':
summary = join(self.summary,'\n')
else:
summary = self.html2text(join(self.summary,''))
return "%s\n\n%s" % (summary,Posting.plain_text(self))
Globals.InitializeClass(Article)
|