def set(self, instance, value=None, **kw): source_text = None if value is None or not self.is_customized(instance): source_text = self.getSourceText(instance, **kw) if source_text: value = source_text now = DateTime() self.setLastUpdate(instance, now) TextField.set(self, instance, value, **kw)
def get(self, instance, mimetype=None, raw=False, forceInline=False, **kwargs): data = TextField.get(self, instance) if(raw or (not forceInline)): return data if(isinstance(data, str) or isinstance(data, unicode)): try: doc = parseString( '<x>%s</x>' % data.strip() ) root = doc.documentElement for child in root.childNodes: if( (child.nodeType == child.TEXT_NODE) and child.data.strip() ): break elif( child.nodeType == child.ELEMENT_NODE ): style = child.getAttribute('style') child.setAttribute('style', u'display:inline;' + style) ## IE hack start ## child.appendChild( doc.createTextNode(' ') ) ## IE hack end ## break tmp = '' for child in root.childNodes: tmp += child.toxml() doc.unlink() data = tmp except: pass return data
def get(self, instance, **kw): if self._isexpired(instance): self.set(instance) return TextField.get(self, instance, **kw)
from Products.CMFCore.permissions import View from Products.CMFCore.utils import getToolByName # the configruation info for this project. from iscorpio.plonepm.config import * # the PPMBuildJournal Schema. PPMBuildJournalSchema = ATCTContent.schema.copy() + Schema(( # The body of the build journal. TextField( 'buildJournalBody', searchable = True, required = True, allowable_content_types = ('text/plain', 'text/structured', 'text/html',), default_output_type = 'text/x-html-safe', widget = RichWidget(label = 'Build Journal Body', rows = 28), ), ), ) # Decide to use the build in plone keywording as the projects selection. # Plone Keywording field is defined as subject in class # Archetypes.ExtensibleMetadata.ExtensibleMetadata # by default this LinesField is located in propertie tab (metadata), # we need move it to the default tab and set it to required. PPMBuildJournalSchema['subject'].schemata = 'default' # used to 'metadata' PPMBuildJournalSchema['subject'].required = True
# the configruation info for this project. from iscorpio.plonepm.config import PROJECTNAME from iscorpio.plonepm.interfaces import IPPMProject __author__ = 'Sean Chen' __email__ = '*****@*****.**' # define a PPMProject as a folder in plone site. PPMProjectSchema = ATFolderSchema.copy() + Schema(( # detail description for this project, it allows rich text. TextField( 'xppm_text', searchable=True, required=True, default_output_type='text/x-html-safe', widget=RichWidget( label='Project body', rows=22, ), ), # developers for this project LinesField( 'xppm_developers', searchable=False, required=True, vocabulary='vocabulary_allMembersList', widget=InAndOutWidget( label='Developers', descrpiton="Please select developers for this project", ),
required=True, vocabulary='vocabulary_allSenders', widget=SelectionWidget( label=u'Sender', description='Set the sender for this email message', format='select', ), ), # memo for this contact. TextField( 'xpcm_emessage_body', searchable=True, required=False, default_output_type='text/x-html-safe', widget=RichWidget( label=u'Email Body', description=u'Please edit your email message here!', rows=22, ), ), # the file attachement. FileField( 'xpcm_emessage_attachment', required=False, searchable=False, storage=AnnotationStorage(migrate=True), widget=FileWidget( label='Attachment', description='You may add one attachment into you email.',
)), StringField('name', required=1, widget=StringWidget( label="Name", description='The name of the person being featured', )), StringField('username', widget=StringWidget( label="Username", description='The userid of the person being featured', )), TextField('description', accessor='Description', required=1, widget=TextAreaWidget( label="Lead In", description='Lead in text for the article', )), TextField('body', default_content_type='text/html', default_output_type='text/html', allowable_content_types=( 'text/structured', 'text/html', 'text/plain', 'text/plain-pre', ), widget=TextAreaWidget( label="Body", description='The main body of the article',
widget=StringWidget(label="Full Name", description="User's Full name."), ), StringField( 'email', languageIndependent=1, required=True, user_property=True, widget=StringWidget(label="Email Address", description="User's Email Address."), ), TextField( 'description', user_property=True, widget=TextAreaWidget( label="Biography", description= "A short overview of who you are and what you do. Will be displayed on the your author page, linked from the items you create." ), ), StringField( 'location', languageIndependent=1, user_property=True, widget=StringWidget(label="Location", description="User's Location."), ), StringField( 'home_page', languageIndependent=1, user_property=True, widget=StringWidget(label="Home Page",
class Sponsor(base.ATCTContent): """A sponsor for a tutor-web site, Department or a Tutorial which could typically be viewed on a tutor-web site or on printed content belonging to tutor-web. Can contain a logo, url and additional text as well as a title. A sponsor is implemented as base contents and uses interface, ISponsor. """ schema = schemata.ATContentTypeSchema.copy() + Schema(( StringField( 'title', required=True, searchable=0, default='tutor-web sponsor', widget=StringWidget(label='Title', description='A title for the sponsor.', i18n_domain='plone'), ), StringField( 'sponsorurl', searchable=0, default='http://sponsor-url.com', widget=StringWidget( label='Specify the web address of the sponsor', description='url for sponsor', ), ), TextField( 'sponsortext', searchable=0, default='', default_content_type='text/plain', allowable_content_types=('text/plain'), widget=TextAreaWidget( label= 'Additional text, more detailed information about the sponsor.', description='additional sponsor text', ), ), ImageField( 'sponsorlogo', #original_size=(600,600), max_size=(200, 200), #sizes={ 'mini' : (80,80), # 'normal' : (200,200), # 'big' : (100,100), # 'maxi' : (500,500), # }, widget=ImageWidget( label='Sponsor logo', description='logo', ), ), )) implements(ISponsor) global_allow = False meta_type = 'Sponsor' # zope type name portal_type = meta_type # plone type name archetype_name = 'Sponsor' # friendly type name _at_rename_after_creation = True #automatically create id security = ClassSecurityInfo() def initializeObject(self): """Called after the creatation of Sponsor publish sponsor so it becomes available for viewing for all users """ self.tryWorkflowAction("publish", ignoreErrors=True) security.declarePrivate('tryWorkflowAction') def tryWorkflowAction(self, action, ignoreErrors=False, comment=None): """publish sponsor""" wtool = self.portal_workflow wf = wtool.getWorkflowsFor(self)[0] if wf.isActionSupported(self, action): if comment is None: #userId = getSecurityManager().getUser().getId() comment = 'State changed' wtool.doActionFor(self, action, comment=comment) elif not ignoreErrors: raise TypeError('Unsupported workflow action %s for object %s.' % (repr(action), repr(self))) def publishAll(self, typeofobject=None, originalobj=None): """publish sponsor""" self.tryWorkflowAction("publish", ignoreErrors=True) def haveChanged(self): parent = aq_parent(self) parenttype = parent.Type() # should use interface instead FIXME # only letting tutorial know of changes not lecture as no sponsor info in lectures at the moment if (parenttype == 'Tutorial'): parent.editedObject()
from Products.Ploneboard.interfaces import IPloneboard from Products.Ploneboard.permissions import AddForum from Products.Ploneboard.permissions import ManageBoard from Products.Ploneboard.permissions import SearchBoard from Products.Ploneboard.permissions import ViewBoard from Products.Archetypes.atapi import AnnotationStorage schema = ATBTreeFolderSchema + Schema(( TextField('description', searchable=1, default_content_type='text/html', default_output_type='text/plain', widget=TextAreaWidget( description="Enter a brief description of the board.", description_msgid="help_description_board", i18n_domain="ploneboard", label="Description", label_msgid="label_description_board", rows=5 ) ), TextField('text', required=False, searchable=True, storage=AnnotationStorage(), validators=('isTidyHtmlWithCleanup',), default_output_type='text/x-html-safe', widget=RichWidget( i18n_domain="ploneboard", label="Text",
widget=OrganisationsWidget( label=_("Data source Organisation"), description=_("Specify data source Organisation"), i18n_domain="eea", visible={ 'edit': 'invisible', 'view': 'invisible' })), TextField( name='body', allowable_content_types=('text/html', ), widget=RichWidget( label="More information", description=("Description of methodology " "and calculations behind this."), label_msgid='daviz_label_body', i18n_domain='eea', ), default_content_type="text/html", searchable=True, default_output_type="text/x-html-safe", required_for_published=False, required=False, ), )) DAVIZ_SCHEMA = ATFolder.schema.copy() + SCHEMA.copy() def finalizeSchema(schema=DAVIZ_SCHEMA): """ Reorder and update schemata """
searchable=True, widget=StringWidget(label='url', description='', label_msgid="label_coreblog_comment_url", description_msgid="help_coreblog_comment_url", i18n_domain="plone", size=60), ), TextField('body', searchable=True, primary=True, index='TextIndex', default_output_type='text/html', default_content_type='text/plain', widget=TextAreaWidget(label='Body', description='', label_msgid="label_coreblog_comment_body", description_msgid="help_coreblog_comment_body", i18n_domain="plone", cols=40,rows=5), ), StringField('post_ip', searchable=True, index='FieldIndex', widget=StringWidget(label='IP', description='', label_msgid="label_coreblog_comment_post_ip", description_msgid="help_coreblog_comment_post_ip", i18n_domain="plone",
def set(self, instance, value, **kwargs): TextField.set(self, instance, value, **kwargs) self.colorise(instance, value, **kwargs)
PBCommentBaseBTreeFolderSchema = BaseBTreeFolderSchema.copy() PBCommentBaseBTreeFolderSchema['title'].read_permission = ViewBoard PBCommentBaseBTreeFolderSchema['title'].write_permission = EditComment schema = PBCommentBaseBTreeFolderSchema + Schema(( TextField('text', searchable=1, default_content_type='text/html', default_output_type='text/x-html-safe', allowable_content_types=('text/html', 'text/plain'), accessor='getText', read_permission=ViewBoard, write_permission=EditComment, widget=RichWidget(description="Enter comment body.", description_msgid="help_text", label="Text", label_msgid="label_text", i18n_domain='ploneboard', rows=5, helper_css=('ploneboard.css',) )), ReferenceField( name='reply_to', accessor='inReplyTo', # Suboptimal accessor naming here... edit_accessor='inReplyToUID', mutator='setInReplyTo', relationship=REPLY_RELATIONSHIP, widget=ReferenceWidget(visible=False),
class Slide(ATFolder): """The basic slide represents a part of a lecture consisting of several slides. The basic component of the tutor-web is the slide. A slide can contain four main components: maintext, and main graphic, explanation text and explanation graphic. Additionally related material relevant to a given slide can be set, detailed material, examples handouts and alternative material. """ IMAGE_FORMATS = DisplayList(( ('none', 'No image'), ('image', 'png, gif or jpeg'), ('fig', 'Fig'), ('r', 'R'), ('gnuplot', 'gnuplot'), )) schema = ATFolderSchema.copy() + Schema(( StringField( 'id', widget=StringWidget( description= 'Change ID to become more readable. Slides appear in alphabetical order based on this value.', modes='edit', ), required=1, ), StringField( 'title', required=True, searchable=0, default='Slide', widget=StringWidget( label='Title', description='The main title of the slide', ), ), ReferenceField( 'ExtraMaterials', widget=ReferenceBrowserWidget( label="Extra material", description='Extra material connected to the slide material.', destination=".", destination_types=("File", ), visible={'edit': 'invisible'}, ), #required = 1, multiValued=True, relationship='hasExtraMaterial', allowed_types=("File", ), ), BooleanField( "UpdateSlideText", default=1, widget=BooleanWidget( label='Update transformable slide text data', description='Check this box if you want transformable text data ' 'to be updated.', ), ), BooleanField( "SlideTextChanged", default=0, widget=BooleanWidget( label= 'This is a control parameter to check if text has been changed recently.', #label_msgid='randomize_answer_order_label', description='Slide is updated if text has been changed.', visible={'edit': 'invisible'}, ), ), TextField( 'SlideText', searchable=0, default_content_type='text/latex', default_output_type='text/latex', accessor='SlideTextRaw', mutator='setSlideText', allowable_content_types=('text/latex', 'text/plain', 'text/structured', 'text/restructured', 'text/html'), widget=RichWidget( label='Main text', description='Main content of the slide', macro='tutorwebtext_notkupu', allow_file_upload=1, ), ), StringField( 'SlideTextView', searchable=0, widget=StringWidget( label='Main text', description='Main content of the slide', macro='tutorwebtext_view', visible={'edit': 'invisible'}, ), ), StringField( 'SlideImageFormat', vocabulary=IMAGE_FORMATS, default='none', widget=SelectionWidget( label='Image format', description= 'Select the format of the main image. It can be a file with format png, gif or jpeg. Or the main image can be rendered from a text based image format of type R, Gnuplot or Fig.', ), ), TextField( 'SlideImageText', allowable_content_types=(), default_output_type='text/plain', default_content_type='text/plain', widget=RichWidget( label='Image definnition', description= 'Main image for slide, displayed to the right of main text of the slide. Possible formats are: fig, gnuplot and R.', allow_file_upload=1, macro='tutorwebtext_notkupu', #condition ='not:object/isImageFormat', ), ), StringField( 'SlideImageCaption', widget=TextAreaWidget( label="Main image caption", description="Main image caption", ), ), ImageField( 'SlideImage', #original_size=(600,600), max_size=(600, 600), #sizes={ 'mini' : (80,80), # 'normal' : (200,200), # 'big' : (100,100), # 'maxi' : (500,500), # }, widget=ImageWidget( label='Slide image', description= 'Main image for slide, displayed to the right of main text of the slide. Possible formats for uploaded images are: png, gif and jpeg.', macro='tutorwebimage', # condition ='object/isImageFormat', )), ImageField( 'SlideImageWWW', max_size=(300, 300), widget=ImageWidget( description= 'Explanation image for slide, displayed at the bottom of the slide to the right of explanation text. Possible formats for uploaded images are: png, gif and jpeg.', macro='tutorwebimage', modes='view', visible={ 'view': 'invisible', 'edit': 'invisible' }, ), ), TextField( 'Explanation', searchable=0, accessor='ExplanationRaw', mutator='setExplanation', default_content_type='text/latex', default_output_type='text/latex', allowable_content_types=( 'text/latex', 'text/plain', 'text/structured', 'text/restructured', 'text/html', ), widget=RichWidget( label='Explanation text', description= 'Explantory material, displayed at the bottom of the slide', macro='tutorwebtext_notkupu_small', allow_file_upload=1, ), ), StringField( 'ExplanationView', searchable=0, widget=StringWidget( label='Main text', description='Main content of the slide', macro='tutorwebtext_view', #macro='tutorwebtext_notkupu', allow_file_upload=1, visible={'edit': 'invisible'}, ), ), StringField( 'ExplanationImageFormat', vocabulary=IMAGE_FORMATS, default='none', widget=SelectionWidget( label='Image format', description= 'Select the format of the explanation image. It can be a file with format png, gif or jpeg. Or the main image can be rendered from a text based image format of type R, Gnuplot or Fig.', #visible = {'edit': 'invisible'}, ), ), TextField( 'ExplanationImageText', allowable_content_types=(), default_output_type='text/plain', default_content_type='text/plain', widget=RichWidget( label='Image definition', description= 'Explanation image for slide, displayed at the bottom of the slide to the right of the explanation text. Possible formats are: fig, gnuplot and R', macro='tutorwebtext_notkupu', allow_file_upload=1, #visible={'edit': 'invisible'}, ), ), StringField( 'ExplanationImageCaption', widget=TextAreaWidget( label="Explanation image caption", description="Explanation image caption", #visible={'edit': 'invisible'}, ), ), ImageField( 'ExplanationImage', max_size=(600, 600), widget=ImageWidget( label='Explanation image', description= 'Explanation image for slide, displayed at the bottom of the slide to the right of explanation text. Possible formats for uploaded images are: png, gif and jpeg.', #visible={'edit':'invisible'}, ), ), ImageField( 'ExplanationImageWWW', max_size=(200, 200), widget=ImageWidget( description= 'Explanation image for slide, displayed at the bottom of the slide to the right of explanation text. Possible formats for uploaded images are: png, gif and jpeg.', macro='tutorwebimage', modes='view', visible={ 'view': 'invisible', 'edit': 'invisible' }, ), ), TextField( 'Details', searchable=0, accessor='DetailsRaw', mutator='setDetails', default_content_type='text/latex', default_output_type='text/html', allowable_content_types=( 'text/latex', 'text/plain', 'text/structured', 'text/restructured', ), widget=RichWidget( description= 'Detailed information on the topic of the slide which can be accessed from the main slide view and is part of the pdf document which can be displayed for each tutorial.', macro='tutorwebtext_notkupu', allow_file_upload=1, ), ), StringField( 'DetailsView', searchable=0, widget=StringWidget( label='Main text', description='Main content of the slide', macro='tutorwebtext_view', visible={'edit': 'invisible'}, ), ), TextField( 'Examples', searchable=0, accessor='ExamplesRaw', mutator='setExamples', default_content_type='text/latex', default_output_type='text/latex', allowable_content_types=('text/latex', 'text/plain', 'text/structured', 'text/restructured', 'text/html'), widget=RichWidget( description= 'Examples for slide which can be accessed from the main slide view and is part of the pdf document which can be displayed for each tutorial.', macro='tutorwebtext_notkupu', allow_file_upload=1, ), ), StringField( 'ExamplesView', searchable=0, widget=StringWidget( label='Main text', description='Main content of the slide', macro='tutorwebtext_view', #macro='tutorwebtext_notkupu', allow_file_upload=1, visible={'edit': 'invisible'}, ), ), TextField( 'Alternative', searchable=0, accessor='AlternativeRaw', mutator='setAlternative', default_content_type='text/latex', default_output_type='text/html', allowable_content_types=( 'text/latex', 'text/plain', 'text/structured', 'text/restructured', 'text/html', ), widget=RichWidget( description= 'Alternate educational material for slide which can be accessed from the main slide view.', macro='tutorwebtext_notkupu', allow_file_upload=1, ), ), StringField( 'AlternativeView', searchable=0, widget=StringWidget( label='Main text', description='Main content of the slide', macro='tutorwebtext_view', visible={'edit': 'invisible'}, ), ), TextField( 'Handout', searchable=0, accessor='HandoutRaw', mutator='setHandout', default_content_type='text/latex', default_output_type='text/html', allowable_content_types=('text/latex', 'text/plain', 'text/structured', 'text/restructured', 'text/html'), widget=RichWidget( description= 'Handout for slide which can be accessed from the main slide view and is part of the pdf document which can be displayed for each tutorial.', macro='tutorwebtext_notkupu', allow_file_upload=1, ), ), StringField( 'HandoutView', searchable=0, widget=StringWidget( label='Main text', description='Main content of the slide', macro='tutorwebtext_view', #macro='tutorwebtext_notkupu', allow_file_upload=1, visible={'edit': 'invisible'}, ), ), TextField( 'SlideReference', searchable=0, accessor='SlideReferenceRaw', mutator='setSlideReference', default_content_type='text/latex', default_output_type='text/html', allowable_content_types=('text/latex', 'text/plain', 'text/structured', 'text/restructured', 'text/html'), widget=RichWidget( label='Reference', description= 'Slide references are printed as part of a pdf document which can be displayed for each tutorial.', macro='tutorwebtext_notkupu', allow_file_upload=1, ), ), StringField( 'SlideReferenceView', searchable=0, widget=StringWidget( label='Main text', description='Main content of the slide', macro='tutorwebtext_view', visible={'edit': 'invisible'}, ), ), )) implements(IPrintable, ISlide, IOrderedTutorWebContent) security = ClassSecurityInfo() # This prevents the Questions from showing up as a portal content type global_allow = False meta_type = 'Slide' # zope type name portal_type = meta_type # plone type name archetype_name = 'Slide' # friendly type name changed = True def useExplanationFig(self): return EXPLANATION_FIG def publishAll(self, typeofobject=None, originalobj=None): '''publich content''' # publish slide self.tryWorkflowAction("publish", ignoreErrors=True) def RawSlideText(self): return self.getRawSlideText() def RawExplanation(self): return self.getRawExplanation() def RawDetails(self): return self.getRawDetails() def RawExamples(self): return self.getRawExamples() def RawAlternative(self): return self.getRawAlternative() def RawHandout(self): return self.getRawHandout() def SlideTextRaw(self): return self.getSlideTextView() def ExplanationRaw(self): return self.getExplanationView() def DetailsRaw(self): return self.getDetailsView() def ExamplesRaw(self): return self.getExamplesView() def AlternativeRaw(self): return self.getAlternativeView() def HandoutRaw(self): return self.getHandoutView() def SlideReferenceRaw(self): return self.getSlideReferenceView() def setSlideText(self, value, **kwargs): '''set main slide text''' f = self.getField('SlideText') f.set(self, value, raw=True, **kwargs) self.setSlideTextView(value) def setSlideTextView(self, value): """update and render appropriate slide text material""" if (self.UpdateSlideText): f = self.getField('SlideTextView') text = self.getRawSlideText() type = self.SlideText.getContentType() value = self.transformText(type, text, 'slidetext') f.set(self, value) self.setSlideTextChanged(1) def setSlideTextView2(self, value): f = self.getField('SlideTextView') f.set(self, value) def setSlideTextView3(self, value): f = self.getField('SlideTextView') text = self.getRawSlideText() type = self.SlideText.getContentType() val = self.transformText(type, text, 'slidetext') f.set(self, val) def setSlideTextView1(self, value): f = self.getField('SlideTextView') text = self.getRawSlideText() type = self.SlideText.getContentType() val = self.transformText(type, text, 'slidetext') f.set(self, val) f1 = self.getField('ExplanationView') text1 = self.getRawExplanation() type1 = self.Explanation.getContentType() value1 = self.transformText(type1, text1, 'explanation') f1.set(self, value1) f2 = self.getField('DetailsView') text2 = self.getRawDetails() type2 = self.Details.getContentType() value2 = self.transformText(type2, text2, 'details') f2.set(self, value2) f3 = self.getField('ExamplesView') text3 = self.getRawExamples() type3 = self.Examples.getContentType() value3 = self.transformText(type3, text3, 'examples') f3.set(self, value3) f4 = self.getField('HandoutView') text4 = self.getRawHandout() type4 = self.Handout.getContentType() value4 = self.transformText(type4, text4, 'handout') f4.set(self, value4) f5 = self.getField('AlternativeView') text5 = self.getRawAlternative() type5 = self.Alternative.getContentType() value5 = self.transformText(type5, text5, 'alternative') f5.set(self, value5) f6 = self.getField('SlideReferenceView') text6 = self.getRawSlideReference() type6 = self.SlideReference.getContentType() value6 = self.transformText(type6, text6, 'reference') f6.set(self, value6) return 'success' def setExplanation(self, value, **kwargs): '''set explanation with raw data and explanation view with transformed data.''' f = self.getField('Explanation') f.set(self, value, raw=True, **kwargs) self.setExplanationView(value) def setExplanationView(self, value): if (self.UpdateSlideText): f = self.getField('ExplanationView') text = self.getRawExplanation() type = self.Explanation.getContentType() value = self.transformText(type, text, 'explanation') f.set(self, value) self.setSlideTextChanged(1) def setDetails(self, value, **kwargs): '''set details text''' f = self.getField('Details') f.set(self, value, raw=True, **kwargs) self.setDetailsView(value) def setDetailsView(self, value): if (self.UpdateSlideText): f = self.getField('DetailsView') text = self.getRawDetails() type = self.Details.getContentType() value = self.transformText(type, text, 'details') f.set(self, value) def setExamples(self, value, **kwargs): '''set examples text''' f = self.getField('Examples') f.set(self, value, raw=True, **kwargs) self.setExamplesView(value) def setExamplesView(self, value): if (self.UpdateSlideText): f = self.getField('ExamplesView') text = self.getRawExamples() type = self.Examples.getContentType() value = self.transformText(type, text, 'examples') f.set(self, value) def setAlternative(self, value, **kwargs): '''set alternative text''' f = self.getField('Alternative') f.set(self, value, raw=True, **kwargs) self.setAlternativeView(value) def setAlternativeView(self, value): if (self.UpdateSlideText): f = self.getField('AlternativeView') text = self.getRawAlternative() type = self.Alternative.getContentType() value = self.transformText(type, text, 'alternative') f.set(self, value) def setHandout(self, value, **kwargs): '''set handout text''' f = self.getField('Handout') f.set(self, value, raw=True, **kwargs) self.setHandoutView(value) def setHandoutView(self, value): if (self.UpdateSlideText): f = self.getField('HandoutView') text = self.getRawHandout() type = self.Handout.getContentType() value = self.transformText(type, text, 'handout') f.set(self, value) def setSlideReference(self, value, **kwargs): '''set slide reference''' f = self.getField('SlideReference') f.set(self, value, raw=True, **kwargs) self.setSlideReferenceView(value) def setSlideReferenceView(self, value): if (self.UpdateSlideText): f = self.getField('SlideReferenceView') text = self.getRawSlideReference() type = self.SlideReference.getContentType() value = self.transformText(type, text, 'reference') f.set(self, value) def setSlideImageW(self): # only works for image for the moment value = self.getSlideImage() #calc heigth and width if (value): f = self.getField('SlideImageWWW') f.set(self, value) if (EXPLANATION_FIG): value = self.getExplanationImage() #calc heigth and width if (value): f = self.getField('ExplanationImageWWW') f.set(self, value) self.changed = False security.declarePublic('imageHasChanged') def imageHasChanged(self): return self.changed security.declarePublic('getSlideImageFactor') def getSlideImageFactor(self, maxw, maxh, fieldname): #ct, width, heigth = getImageInfo(self.getSlideImage()) #value = self.getSlideImage() #calc heigth and width #f = self.getField('SlideImageWWW') #f.set(self, value) f = self.getField(fieldname) #w = f.getAttr(self, 'width') width, heigth = f.getSize(self) #width = 350 #heigth = 120 if width > maxw or \ heigth > maxh: factor = min(float(300) / float(width), float(300) / float(heigth)) else: factor = 1 return factor #return w def getImage(self): return 1, 1 security.declarePrivate('initializeObject') def initializeObject(self): self.tryWorkflowAction("publish", ignoreErrors=True) parent = aq_parent(self) parent.orderObjects("id") parent.plone_utils.reindexOnReorder(parent) #self.reindexObject() self.changed = True self.renderImages() def editedObject(self, objtype=None): parent = aq_parent(self) parent.editedObject() self.renderImages() def renderImages(self): self.renderMainImage() if (EXPLANATION_FIG): self.renderExplanationImage() self.setSlideImageW() def setChanged(self, ch): #self.changed = ch lec = aq_parent(self) lec.setChanged(True) def setChanged(self, ch): #self.changed = ch lec = aq_parent(self) lec.setChanged(True) tut = aq_parent(lec) tut.setChanged(True) security.declarePrivate('tryWorkflowAction') def tryWorkflowAction(self, action, ignoreErrors=False, comment=None): wtool = self.portal_workflow wf = wtool.getWorkflowsFor(self)[0] if wf.isActionSupported(self, action): if comment is None: #userId = getSecurityManager().getUser().getId() comment = 'State changed' wtool.doActionFor(self, action, comment=comment) elif not ignoreErrors: raise TypeError('Unsupported workflow action %s for object %s.' % (repr(action), repr(self))) def haveChanged(self): self.changed = True self.renderImages() security.declareProtected(View, 'transformSlideText') def transformSlideText(self, val): type = self.SlideText.getContentType() data = self.transformText(type, val, 'slidetext') self.setSlideTextView(data) security.declareProtected(View, 'updateTransformableText') def updateTransformableText(self): #use loop to go through everything... type = self.SlideText.getContentType() transformtext = self.getRawSlideText() data = self.transformText(type, transformtext, 'slidetext') #self.setSlideTextView(data) f = self.getField('SlideTextView') f.set(self, data) #self.SlideTextView.setContentType(self, 'text/html') type = self.Explanation.getContentType() transformtext = self.getRawExplanation() data = self.transformText(type, transformtext, 'explanation') self.setExplanationView(data) #self.ExplanationView.setContentType(self, 'text/html') type = self.Details.getContentType() transformtext = self.getRawDetails() data = self.transformText(type, transformtext, 'details') self.setDetailsView(data) #self.DetailsView.setContentType(self, 'text/html') type = self.Examples.getContentType() transformtext = self.getRawExamples() data = self.transformText(type, transformtext, 'examples') self.setExamplesView(data) #self.ExamplesView.setContentType(self, 'text/html') type = self.Alternative.getContentType() transformtext = self.getRawAlternative() data = self.transformText(type, transformtext, 'alternative') self.setAlternativeView(data) #self.AlternativeView.setContentType(self, 'text/html') type = self.Handout.getContentType() transformtext = self.getRawHandout() data = self.transformText(type, transformtext, 'handout') self.setHandoutView(data) #self.HandoutView.setContentType(self, 'text/html') type = self.SlideReference.getContentType() transformtext = self.getRawSlideReference() data = self.transformText(type, transformtext, 'reference') self.setSlideReferenceView(data) #self.SlideReferenceView.setContentType(self, 'text/html') security.declareProtected(View, 'transformText') def transformText(self, type, text, origin): trans = getToolByName(self, 'portal_transforms') data = trans.convertTo('text/html', text, mimetype=type, usedby=self) objects = data.getSubObjects() #mobj = data.getMetadata()['fileName'] #for d in mobj: # mobj = 'bla' counter = 0 for x in objects: if hasattr(self, x): self.manage_delObjects([x]) if hasattr(self, origin + x): self.manage_delObjects([origin + x]) self.manage_addImage(origin + x, objects[x]) container = self[origin + x] counter = counter + 1 #tempname = container.getTitle() #container.setTitle('bla') container.manage_permission( permissions.View, roles=["Anonymous", "Authenticated", "Manager"], acquire=False) container.manage_permission( 'Delete objects', roles=["Anonymous", "Authenticated", "Manager"], acquire=False) transformedtext = data.getData() if (type == 'text/latex'): path = '/'.join(self.getPhysicalPath()) transformedtext = transformedtext.replace('SRC="', 'SRC="' + path + '/') for x in objects: transformedtext = transformedtext.replace(x, origin + x) self.reindexObject() return transformedtext def isImageFormat(self): image_type = self.getSlideimageFormat() if (image_type == 'image'): return True else: return False def renderMainImage(self): # should add checkes for if it empy, try, except code as well... image_type = self.getSlideImageFormat() rendered_image = 'DELETE_IMAGE' text = self.getSlideImageText() im = self.getSlideImage() if (im and (image_type != 'image')): self.setSlideImage(rendered_image) if ((len(text) > 0) and ((image_type == 'image') or (image_type == 'none'))): self.setSlideImageText('') if (image_type == 'fig'): rendered_image = self.renderImage(text, 'fig2dev -L png', '') elif (image_type == 'gnuplot'): HEADER = 'set terminal png color\n' rendered_image = self.renderImage(text, 'gnuplot', HEADER) elif (image_type == 'r'): #HEADER = 'png(file="/dev/stdout")\r\n' HEADER = 'bitmap(file="/dev/stdout")\r\n' #rendered_image = self.renderImage(text, 'R --slave', HEADER) rendered_image = self.renderRQuestion(text, HEADER) else: ''' do nothing for the moement ''' if (image_type != 'image'): if (rendered_image != 'FAILURE'): try: self.setSlideImage(rendered_image) return True except: return False else: return False else: ''' Return true if image type is png, jpeg, gif - no rendering needed.''' return True def renderExplanationImage(self): # should add checkes for if it empy, try, except code as well... image_type = self.getExplanationImageFormat() text = self.getExplanationImageText() rendered_image = 'DELETE_IMAGE' im = self.getExplanationImage() if (im and (image_type != 'image')): self.setExplanationImage(rendered_image) if ((len(text) > 0) and ((image_type == 'image') or (image_type == 'none'))): self.setExplanationImageText('') if (image_type == 'fig'): rendered_image = self.renderImage(text, 'fig2dev -L png', '') elif (image_type == 'gnuplot'): HEADER = 'set terminal png color\n' rendered_image = self.renderImage(text, 'gnuplot', HEADER) elif (image_type == 'r'): #HEADER = 'postscript(file="/dev/stdout")\r\n' #HEADER = 'png(file="/dev/stdout")\r\n' HEADER = 'bitmap(file="/dev/stdout")\r\n' #rendered_image = self.renderImage(text, 'R --slave', HEADER) rendered_image = self.renderRQuestion(text, HEADER) #if (rendered_image != 'DELETE_IMAGE'): # rendered_image = twutils.ps2png(rendered_image) else: ''' do nothing for the moement ''' if (image_type != 'image'): if (rendered_image != 'FAILURE'): self.setExplanationImage(rendered_image) return True else: return False else: return True security.declarePublic("renderRQuestion") def renderRQuestion(self, questiontext, HEADER): "jaso" tmpout = tempfile.mkdtemp() png_fd, png_absname = tempfile.mkstemp(dir=tmpout, suffix='.png') render = False setdatafiles = False if ('read' or 'source' in questiontext): tmpout1 = tempfile.mkdtemp() setdatafiles = True parent = aq_parent(self) extradata = parent.getAllExtraFiles() for ext in extradata: extra = ext.getObject() filename = extra.getTitle() extraid = extra.getId() f = open(tmpout1 + '/' + extraid, 'w') text = str(extra.getField('file').get(extra).data) for ex in extradata: extobj = ex.getObject() extid = extobj.getId() if (extid in text): text = text.replace(extid, '/' + tmpout1 + '/' + extid) f.write(text) f.close() if (extraid in questiontext): text = str(extra.getField('file').get(extra).data) questiontext = questiontext.replace( extraid, '/' + tmpout1 + '/' + extraid) try: stdin, stdout = os.popen2('R --slave') try: stdin.write('bitmap(file="' + png_absname + '")\r\n') except: return 'FAILURE' try: stdin.write(questiontext) stdin.write('\r\n') stdin.write('dev.off()') try: stdin.flush() try: stdin.close() try: s = stdout.read( ) #s should be of the form %s|%s|%s|%s try: stdout.flush() render = True try: stdout.close() except: ''' bla bla''' except: ''' bla bla''' except: ''' bla bla''' except: '''bla bla''' except: '''bla bla''' except: '''bla bla''' except: render = False # if exists png file then read data and set # else set png file as empty DELETE_IMAGE try: mainimagefile = open(png_absname, 'r') except: '''Could not open image file??''' return 'FAILURE' try: mainimage = mainimagefile.read() except: '''could not read from image file???''' return 'FAILURE' mainimagefile.close() #try: # if (mainimage): # self.setQuestionImage(mainimage) # else: # self.setQuestionImage('DELETE_IMAGE') #except: # '''????''' #if (render is True): # s = s.split("|") #else: # s = questiontext.split("|") #remove temporary directories created by the use of tempfile # and close file os.close(png_fd) try: shutil.rmtree(tmpout, True) if (setdatafiles): shutil.rmtree(tmpout1, True) except OSError, (errno, strerror): print "tutorial pdf:(shutil.rmtree %s) OSError[%s]: %s" % \ (tmpout, errno, strerror) if (mainimage): return mainimage else: return 'DELETE_IMAGE'
searchable=True, required=False, vocabulary="vocabulary_contactGroups", widget=InAndOutWidget( label=u'Groups', description="Please select groups for this person", ), schemata='Contact', ), # memo for this contact. TextField( 'xpcm_contact_memo', searchable=True, required=False, default_output_type='text/x-html-safe', widget=RichWidget( label=u'Contact Memo', rows=22, ), ), ), ) # Plone 3 will re-organize all fields' shemata by using this method. finalizeATCTSchema(XPointContactSchema) # the class. class XPointContact(ATCTContent): """ ATContentType for a Contact """
from Products.CMFCore.utils import getToolByName # the configruation info for this project. from Products.XPointProjectManagement.config import PROJECTNAME # the schema for XPointTask. XPointTaskSchema = ATFolderSchema.copy() + Schema( ( # text field for details description for this task. TextField( 'xptask_text', searchable=True, required=True, default_output_type='text/x-html-safe', widget=RichWidget( label='Task description', rows=25, ), ), # planned completed date, 90% finish deadline DateTimeField( 'xptask_completion_date', index='DateIndex:schema', searchable=False, required=True, widget=CalendarWidget( label='90% Completion Deadline', description= 'Specify the date when this task should be completed at less 90%',
LinesField( 'BatchLabels', vocabulary="BatchLabelVocabulary", accessor="getLabelNames", widget=MultiSelectionWidget( label=_("Batch Labels"), format="checkbox", ) ), TextField( 'Remarks', default_content_type='text/x-web-intelligent', allowable_content_types=('text/plain', ), default_output_type="text/plain", widget=TextAreaWidget( macro="bika_widgets/remarks", label=_('Remarks'), append_only=True, ) ), ReferenceField( 'InheritedObjects', required=0, multiValued=True, allowed_types=('AnalysisRequest'), # batches are expanded on save referenceClass=HoldingReference, relationship='BatchInheritedObjects', widget=ReferenceWidget( visible=False,
widget=StringWidget(label='Subtitle', description='', label_msgid='label_subtitle', description_msgid='help_subtitle', i18n_domain='plone', size=60), ), TextField( 'body', required=True, primary=True, searchable=True, index='TextIndex', default_output_type='text/html', default_content_type='text/html', allowable_content_types=zconf.coreblog2.allowed_content_types, widget=RichWidget(label='Body', description='', label_msgid='label_body', description_msgid='help_body', i18n_domain='plone', allow_file_upload=False, cols=40, rows=30), ), TextField( 'extend', searchable=True, index='TextIndex', default_output_type='text/html', default_content_type='text/html', allowable_content_types=zconf.coreblog2.allowed_content_types,
{ "columnName": "Title", "label": "Title" }, { "columnName": "ClientTitle", "label": "Client" }, ], ), ), RecordField( "Metadata", multiValued=True, ), TextField("Html"), BlobField( "Pdf", default_content_type="application/pdf", ), RecordsField( "Recipients", type="recipients", subfields=("UID", "Username", "Fullname", "EmailAddress", "PublicationModes"), ), DateTimeField( "DatePrinted", mode="rw", widget=DateTimeWidget(label=_("Date Printed"), visible={
from quills.app.topic import Topic from quills.app.topic import AuthorTopic from quills.app.utilities import QuillsMixin from quills.app.interfaces import IWeblogEnhancedConfiguration # Local imports from .config import PROJECTNAME from . import permissions as perms WeblogEntrySchema = BaseSchema.copy() + Schema( ( TextField( 'description', searchable=1, accessor='Description', widget=TextAreaWidget( label=_('label_weblogentry_description', default='Excerpt'), description=_('help_weblogentry_description', default='A brief introduction for this entry.'), ), ), TextField( 'text', searchable=1, default_output_type='text/x-html-safe', widget=RichWidget( label=_('label_text', default='Entry Text'), rows=30, ), ), ), marshall=RFC822Marshaller(),
"Composite", default=False, widget=BooleanWidget( label=_("Composite sample"), description=_("The sample is a mix of sub samples"), ), ), BooleanField( "SamplingRequired", default_method='getSamplingRequiredDefaultValue', widget=BooleanWidget( label=_("Sample collected by the laboratory"), description=_("Enable sampling workflow for the created sample")), ), TextField("Remarks", allowable_content_types=("text/plain", ), widget=TextAreaWidget(label=_("Remarks"), )), RecordsField( "Partitions", schemata="Sample Partitions", required=0, type="artemplate_parts", subfields=("part_id", "Container", "Preservation", "SampleType", "container_uid", "preservation_uid", "sampletype_uid"), subfield_labels={ "part_id": _("Partition"), "Container": _("Container"), "Preservation": _("Preservation"), "SampleType": _("Sample Type") }, subfield_sizes={
from iscorpio.plonepm.interfaces import IPPMIteration __author__ = "Sean Chen" __email__ = "*****@*****.**" # the schema. PPMIterationSchema = ATCTContent.schema.copy() + Schema( ( # the details description for a iteration. TextField( 'xppm_text', searchable=True, required=True, default_output_type='text/x-html-safe', widget=RichWidget( label=u'Iteration Plan', description=u'The details plan about this iteration.', rows=25, ), ), # target completed date. DateTimeField( 'xppm_completion_date', searchable=False, required=True, widget=CalendarWidget( label='Target Completion Date', description= 'Specify the date when this iteration should be completed',
class NewsletterRichReference(BaseContent, PropertyManager): portal_type = meta_type = 'NewsletterRichReference' archetype_name = 'Newsletter RichReference' #this name appears in the 'add' box security = ClassSecurityInfo() schema = BaseSchema + Schema(( TextField('text', default='', searchable=1, required=1, default_output_type='text/x-html-safe', widget=RichWidget(label='Text', description='', label_msgid='label_text', description_msgid='help_text', i18n_domain="plone")), ImageField( name='image', widget=ImageWidget( label_msgid="label_preview_image", description= "This image is used as preview for the referenced objects.", description_msgid="help_image", label='Preview image', i18n_domain='plonegazette', ), storage=AttributeStorage(), sizes={ 'normal': (200, 130), }), ReferenceField( 'references', languageIndependent=1, required=0, allowed_types=(), multiValued=1, relationship='references', widget=ReferenceBrowserWidget( label='References', description='Select one or more remote objects', label_msgid='label_references', description_msgid='help_references', i18n_domain='plonegazette', allow_search=1, allow_browse=1, show_indexes=0, ), ), )) # Make sure we get title-to-id generation when an object is created _at_rename_after_creation = True security.declarePublic('getObjects') def getObjects(self): """ """ return self.getReferences() security.declareProtected(View, 'imagetag') def imagetag(self, **kwargs): """Generate image tag using the api of the ImageField this method is needed because one must not access ImageField.tag in pagetemplates """ if 'title' not in kwargs: kwargs['title'] = self.Title() return self.getField('image').tag(self, **kwargs) # uncommant lines below when you need factory_type_information = { 'allowed_content_types': [], 'global_allow': 0, 'content_icon': 'NewsletterReference.gif', 'immediate_view': 'newsletterreference_view', 'filter_content_types': 0 } actions = ({ 'id': 'view', 'name': 'View', 'category': 'object', 'action': 'string:${object_url}/NewsletterRichReference_view', 'permissions': ('View', ) }, )
checkbox_bound=0, label=_("Task type", "Type"), ), ), RecordsField( "ScheduleCriteria", required=1, type="schedulecriteria", widget=ScheduleInputWidget(label=_("Criteria"), ), ), TextField( "Considerations", default_content_type="text/plain", allowed_content_types=("text/plain", ), default_output_type="text/plain", widget=TextAreaWidget( label=_("Considerations"), description=_("Remarks to take into account before performing the " "task"), ), ), )) IdField = schema['id'] schema['description'].required = False schema['description'].widget.visible = True schema['description'].schemata = 'default' schema.moveField('description', before='Considerations') # Title is not needed to be unique schema['title'].validators = ()
from iscorpio.plonepm.content.base import XPPMBase __author__ = 'Sean Chen' __email__ = '*****@*****.**' __docformat__ = 'plaintext' # define a PPMProject as a folder in plone site. PPMResponseSchema = ATCTContent.schema.copy() + Schema(( # artifact details TextField( 'xppm_text', searchable = True, required = True, default_output_type = 'text/x-html-safe', widget = RichWidget( label = 'Details', description = 'Details description for your response', rows = 18, ), ), # artifact category StringField( 'xppm_response_category', mutator = 'setXppm_response_category', searchable = False, required = True, vocabulary = 'vocabulary_categories', widget = SelectionWidget( label = 'Artifact Category',
newId = str(self.getNextUniqueId()) self.log.info('the next value for xppm sequence: %s', newId) self.setId(self.xppm_id_prefix + newId) # the base class for all document base content in XPoint Project Management XPPMDocBaseSchema = ATCTContent.schema.copy() + Schema( ( # the details description for a use case. TextField( 'xppm_text', searchable=True, required=True, default_output_type='text/x-html-safe', widget=RichWidget( label=u'Text Area Label', description=u'The details description Here.', rows=25, ), ), # the status for this issue. StringField( 'xppm_status', searchable=False, required=False, default='', # this the default vocabulary, we can change for each one. vocabulary='vocabulary_status', widget=SelectionWidget(
AttachmentSizes = IntDisplayList(( (10, _(u'10 kilobyte')), (100, _(u'100 kilobyte')), (1000, _(u'1 megabyte')), (10000, _(u'10 megabyte')), (-1, _(u'unlimited')), )) schema = BaseBTreeFolderSchema + Schema(( TextField('description', searchable=1, default_content_type='text/html', default_output_type='text/plain', widget=TextAreaWidget( description="Brief description of the forum topic.", description_msgid="help_description_forum", label="Description", label_msgid="label_description_forum", i18n_domain="ploneboard", rows=5)), LinesField( 'category', write_permission=ManageForum, vocabulary='getCategories', widget=MultiSelectionWidget( description="Select which category the forum should be listed " "under. A forum can exist in multiple categories, " "although using only one category is recommended.", description_msgid="help_category", condition="object/getCategories",
required=0, validators=("uniquefieldvalidator",), widget=StringWidget( visible={"view": "visible", "edit": "visible"}, label=_("Method ID"), description=_("Define an identifier code for the method. " "It must be unique."), ), ), TextField( "Instructions", default_content_type="text/plain", allowed_content_types=("text/plain", ), default_output_type="text/plain", widget=TextAreaWidget( label=_("Instructions"), description=_("Technical description and instructions " "intended for analysts"), ), ), BlobFileField( "MethodDocument", # XXX Multiple Method documents please widget=FileWidget( label=_("Method Document"), description=_("Load documents describing the method here"), ) ), # The instruments linked to this method. Don't use this
description='Price for your item -- do NOT include currency symbols!', label_msgid='label_price', description_msgid='help_price', i18n_domain='simplecartitem', ), validator='isDecimal', ), TextField( name = 'description', searchable = True, widget = TextAreaWidget( label='Basic Description', description='Short description of the item; it will show up in listing views.', allow_file_upload = False, label_msgid='label_description', description_msgid='help_description', i18n_domain='simplecartitem', ), isMetadata=True, accessor='Description', default_output_type='text/plain', allowable_content_types=('text/plain',), ), TextField( name = 'short_description', searchable = True, widget=RichWidget( label='Extended Description', description='Detailed description of the item.', allow_file_upload = False,
"AccreditationBodyLogo", schemata="Accreditation", widget=ImageWidget( label=_("Accreditation Logo"), description=_( "Please upload the logo you are authorised to use on your " "website and results reports by your accreditation body. " "Maximum size is 175 x 175 pixels.")), ), TextField( "AccreditationPageHeader", schemata="Accreditation", default=DEFAULT_ACCREDITATION_PAGE_HEADER, widget=TextAreaWidget( label=_("Accreditation page header"), description=_( "Enter the details of your lab's service accreditations here. " "The following fields are available: lab_is_accredited, " "lab_name, lab_country, confidence, accreditation_body_name, " "accreditation_standard, accreditation_reference<br/>"), rows=10), ), )) IdField = schema["id"] IdField.widget.visible = {"edit": "hidden", "view": "invisible"} schema["Name"].validators = () # Update the validation layer after change the validator in runtime schema["Name"]._validationLayer()
tags = LinesField( 'tags', #required=1, searchable=1, index="lens_catalog/KeywordIndex:brains", widget=LinesWidget( label="Tags", # TODO: TagsWidget? description=tagsdesc, i18n_domain="rhaptos"), ) commentdesc = "" comment = TextField( 'comment', # overrides default required=0, index="lens_catalog/:brains", widget=TextAreaWidget( label="Comments", description=commentdesc, )) plaincomment = ComputedField( 'plainComment', searchable=0, index="lens_catalog/:brains", expression="context.getComment(mimetype='text/plain')", widget=StringWidget(modes=()), ) allowedRolesAndUsers = ComputedField( 'allowedRolesAndUsers', accessor="allowedRolesAndUsers",