class TwitterControlPanelAdapter(BaseControlPanelAdapter): """ Twitter control panel adapter """ adapts(IPloneSiteRoot) implements(ITwitterSchema) twitter_enabled = ProxyFieldProperty(ITwitterSchema['twitter_enabled']) twittvia = ProxyFieldProperty(ITwitterSchema['twittvia'])
class LinkSchemaAdapter(SchemaAdapterBase): adapts(IMutableLink) implements(ILinkSchema) title = ProxyFieldProperty(ILinkSchema['title'], 'Title') remote_url = ProxyFieldProperty(ILinkSchema['remote_url'])
class BarraControlPanelAdapter(SchemaAdapterBase): ''' Adapter para a raiz do site Plone suportar o schema de configuracao da barra de identidade Esta classe implementa uma maneira da raiz do site armazenar as configuracoes que serao geridas pelo painel de controle ''' adapts(IPloneSiteRoot) implements(IBarraConfSchema) def __init__(self, context): super(BarraControlPanelAdapter, self).__init__(context) # Obtem a tool portal_properties portal_properties = getToolByName(context, 'portal_properties') # Define que o contexto a ser utilizado para o schema IBarraConfSchema # sera a property sheet brasil_gov self.context = portal_properties.brasil_gov # Define que o atributo local do schema sera armazenado como propriedade # dentro deste contexto local = ProxyFieldProperty(IBarraConfSchema['local']) # Define que o atributo cor do schema sera armazenado como propriedade # dentro deste contexto cor = ProxyFieldProperty(IBarraConfSchema['cor'])
class LikeControlPanelAdapter(BaseControlPanelAdapter): """ Like control panel adapter """ adapts(IPloneSiteRoot) implements(IProvidersSchema) enabled_portal_types = ProxyFieldProperty( IProvidersSchema['enabled_portal_types']) typebutton = ProxyFieldProperty(IProvidersSchema['typebutton'])
class FbControlPanelAdapter(BaseControlPanelAdapter): """ Facebook control panel adapter """ adapts(IPloneSiteRoot) implements(IFbSchema) fb_enabled = ProxyFieldProperty(IFbSchema['fb_enabled']) fb_typebutton = ProxyFieldProperty(IFbSchema['fb_typebutton']) fbaction = ProxyFieldProperty(IFbSchema['fbaction']) fbadmins = ProxyFieldProperty(IFbSchema['fbadmins'])
class RedmineControlPanelAdapter(BaseControlPanelAdapter): """ Redmine settings control panel adapter """ adapts(IPloneSiteRoot) implements(IRedmineSchema) redmine_url = ProxyFieldProperty(IRedmineSchema['redmine_url']) version = ProxyFieldProperty(IRedmineSchema['version']) user_api_key = ProxyFieldProperty(IRedmineSchema['user_api_key']) project = ProxyFieldProperty(IRedmineSchema['project'])
class CalendarControlPanelAdapter(SchemaAdapterBase): adapts(IPloneSiteRoot) implements(ICalendarSchema) def __init__(self, context): super(CalendarControlPanelAdapter, self).__init__(context) self.context = getToolByName(context, 'portal_calendar') firstweekday = ProxyFieldProperty(ICalendarSchema['firstweekday']) calendar_states = ProxyFieldProperty(ICalendarSchema['calendar_states'])
class ImagingControlPanelAdapter(SchemaAdapterBase): adapts(IPloneSiteRoot) implements(IImagingSchema) def __init__(self, context): super(ImagingControlPanelAdapter, self).__init__(context) self.context = getUtility(IPropertiesTool).imaging_properties allowed_sizes = ProxyFieldProperty(IImagingSchema['allowed_sizes']) quality = ProxyFieldProperty(IImagingSchema['quality'])
class MinimalMetadataSchemaAdapter(SchemaAdapterBase): """Adapter for IMutableMinimalDublinCore. """ adapts(IMutableMinimalDublinCore) implements(IMinimalMetadataSchema) title = ProxyFieldProperty(IMetadataSchema['title'], 'Title', 'setTitle') description = ProxyFieldProperty(IMetadataSchema['description'], 'Description', 'setDescription')
class CookiePolicyControlPanelAdapter(BaseControlPanelAdapter): """ Cookie Policy control panel adapter """ adapts(IPloneSiteRoot) implements(ICookiePolicySchema) TCP_enabled = ProxyFieldProperty(ICookiePolicySchema['TCP_enabled']) TCP_title = ProxyFieldProperty(ICookiePolicySchema['TCP_title']) TCP_message = ProxyFieldProperty(ICookiePolicySchema['TCP_message']) TCP_submit_button = ProxyFieldProperty( ICookiePolicySchema['TCP_submit_button'])
class EasyslideshowControlPanelAdapter(SchemaAdapterBase): adapts(IPloneSiteRoot) implements(IEasyslideshowConfiguration) def __init__(self, context): super(EasyslideshowControlPanelAdapter, self).__init__(context) self.context = getUtility(IPropertiesTool).easyslideshow_properties slideshow_width = ProxyFieldProperty( IEasyslideshowConfiguration['slideshow_width']) slideshow_height = ProxyFieldProperty( IEasyslideshowConfiguration['slideshow_height']) slide_timeout = ProxyFieldProperty( IEasyslideshowConfiguration['slide_timeout']) transition = ProxyFieldProperty(IEasyslideshowConfiguration['transition']) transition_speed = ProxyFieldProperty( IEasyslideshowConfiguration['transition_speed']) pause_hover = ProxyFieldProperty( IEasyslideshowConfiguration['pause_hover']) display_nav = ProxyFieldProperty( IEasyslideshowConfiguration['display_nav']) display_caption = ProxyFieldProperty( IEasyslideshowConfiguration['display_caption']) random_order = ProxyFieldProperty( IEasyslideshowConfiguration['random_order'])
class SiteControlPanelAdapter(SchemaAdapterBase): adapts(IPloneSiteRoot) implements(ISiteSchema) def __init__(self, context): super(SiteControlPanelAdapter, self).__init__(context) self.portal = getSite() pprop = getToolByName(self.portal, 'portal_properties') self.context = pprop.site_properties self.encoding = pprop.site_properties.default_charset def get_site_title(self): title = getattr(self.portal, 'title', u'') return safe_unicode(title) def set_site_title(self, value): self.portal.title = value.encode(self.encoding) def get_site_description(self): description = getattr(self.portal, 'description', u'') return safe_unicode(description) def set_site_description(self, value): if value is not None: self.portal.description = value.encode(self.encoding) else: self.portal.description = '' def get_webstats_js(self): description = getattr(self.context, 'webstats_js', u'') return safe_unicode(description) def set_webstats_js(self, value): if value is not None: self.context.webstats_js = value.encode(self.encoding) else: self.context.webstats_js = '' site_title = property(get_site_title, set_site_title) site_description = property(get_site_description, set_site_description) webstats_js = property(get_webstats_js, set_webstats_js) enable_sitemap = ProxyFieldProperty(ISiteSchema['enable_sitemap']) exposeDCMetaTags = ProxyFieldProperty(ISiteSchema['exposeDCMetaTags']) def get_display_pub_date_in_byline(self): return getattr(self.context.site_properties, 'displayPublicationDateInByline', False) def set_display_pub_date_in_byline(self, value): self.context.site_properties.displayPublicationDateInByline = value display_pub_date_in_byline = property(get_display_pub_date_in_byline, set_display_pub_date_in_byline)
class FileSchemaAdapter(SchemaAdapterBase): """Adapter for IMutableFile. """ adapts(IMutableFile) implements(IFileSchema) title = ProxyFieldProperty(IFileSchema['title'], 'Title') description = ProxyFieldProperty(IFileSchema['description'], 'Description') format = ProxyFieldProperty(IFileSchema['format'], 'Format') upload = ProxyFieldProperty(IFileSchema['upload'], 'data', 'manage_upload')
class LinkSchemaAdapter(SchemaAdapterBase): adapts(IMutableLink) implements(ILinkSchema) title = ProxyFieldProperty(ILinkSchema['title'], 'Title', 'setTitle') language = ProxyFieldProperty(ILinkSchema['language'], 'Language', 'setLanguage') description = ProxyFieldProperty(ILinkSchema['description'], 'Description', 'setDescription') remote_url = ProxyFieldProperty(ILinkSchema['remote_url'])
class UserGroupsSettingsControlPanelAdapter(SchemaAdapterBase): adapts(IPloneSiteRoot) implements(IUserGroupsSettingsSchema) def __init__(self, context): super(UserGroupsSettingsControlPanelAdapter, self).__init__(context) pprop = getToolByName(context, 'portal_properties') self.context = pprop.site_properties many_groups = ProxyFieldProperty(IUserGroupsSettingsSchema['many_groups']) many_users = ProxyFieldProperty(IUserGroupsSettingsSchema['many_users'])
class ExternalEditorControlPanelAdapter(SchemaAdapterBase): """ """ adapts(IPloneSiteRoot) implements(IExternalEditorSchema) def __init__(self, context): super(ExternalEditorControlPanelAdapter, self).__init__(context) ext_editor = ProxyFieldProperty(IExternalEditorSchema['ext_editor']) externaleditor_enabled_types = ProxyFieldProperty( IExternalEditorSchema['externaleditor_enabled_types'])
class NewsItemSchemaAdapter(SchemaAdapterBase): """Adapter for IMutableNewsItem. """ adapts(IMutableNewsItem) implements(INewsItemSchema) title = ProxyFieldProperty(INewsItemSchema['title'], 'Title') text_format = ProxyFieldProperty(INewsItemSchema['text_format']) description = ProxyFieldProperty(INewsItemSchema['description'], 'Description', 'setDescription') text = ProxyFieldProperty(INewsItemSchema['text'], 'EditableBody', '_edit')
class DropdownControlPanelAdapter(SchemaAdapterBase): adapts(IPloneSiteRoot) implements(IDropdownConfiguration) def __init__(self, context): super(DropdownControlPanelAdapter, self).__init__(context) self.context = getUtility(IPropertiesTool).dropdown_properties dropdown_depth = ProxyFieldProperty( IDropdownConfiguration['dropdown_depth']) enable_caching = ProxyFieldProperty( IDropdownConfiguration['enable_caching']) enable_parent_clickable = ProxyFieldProperty( IDropdownConfiguration['enable_parent_clickable'])
class DocumentSchemaAdapter(SchemaAdapterBase): """Adapter for IMutableDocument. """ adapts(IMutableDocument) implements(IDocumentSchema) safety_belt = ProxyFieldProperty(IDocumentSchema['safety_belt'], '_safety_belt') title = ProxyFieldProperty(IDocumentSchema['title'], 'Title') description = ProxyFieldProperty(IDocumentSchema['description'], 'Description') text_format = ProxyFieldProperty(IDocumentSchema['text_format']) upload = None text = ProxyFieldProperty(IDocumentSchema['text'], 'EditableBody', '_edit')
class SEOConfigletAdapter(SchemaAdapterBase): adapts(IPloneSiteRoot) implements(ISEOConfigletSchema) def __init__(self, context): super(SEOConfigletAdapter, self).__init__(context) self.portal = getSite() pprop = getToolByName(self.portal, 'portal_properties') self.context = pprop.seo_properties self.siteprops = pprop.site_properties self.ttool = getToolByName(context, 'portal_types') self.encoding = pprop.site_properties.default_charset def getExposeDC(self): return self.siteprops.getProperty('exposeDCMetaTags') def setExposeDC(self, value): return self.siteprops._updateProperty('exposeDCMetaTags', bool(value)) def getTypesSEOEnabled(self): ct_with_seo = self.context.content_types_with_seoproperties return [t for t in self.ttool.listContentTypes() if t in ct_with_seo] def setTypesSEOEnabled(self, value): value = [t for t in self.ttool.listContentTypes() if t in value] self.context._updateProperty('content_types_with_seoproperties', value) def getCustomScript(self): description = getattr(self.context, 'custom_script', u'') return safe_unicode(description) def setCustomScript(self, value): if value is not None: self.context.custom_script = value.encode(self.encoding) else: self.context.custom_script = '' exposeDCMetaTags = property(getExposeDC, setExposeDC) seo_default_custom_metatag = ISEOConfigletSchema['default_custom_metatags'] default_custom_metatags = ProxyFieldProperty(seo_default_custom_metatag) metatags_order = ProxyFieldProperty(ISEOConfigletSchema['metatags_order']) types_seo_enabled = property(getTypesSEOEnabled, setTypesSEOEnabled) custom_script = property(getCustomScript, setCustomScript) fields = ProxyFieldProperty(ISEOConfigletSchema['fields']) stop_words = ProxyFieldProperty(ISEOConfigletSchema['stop_words']) seo_external_keywords_test = ISEOConfigletSchema['external_keywords_test'] external_keywords_test = ProxyFieldProperty(seo_external_keywords_test)
class FavoriteSchemaAdapter(SchemaAdapterBase): adapts(IMutableFavorite) implements(IFavoriteSchema) _remote_url = ProxyFieldProperty(IFavoriteSchema['remote_url']) def _getRemoteURL(self): return self._remote_url def _setRemoteURL(self, value): self._remote_url = value self.context.remote_uid = self.context._getUidByUrl() title = ProxyFieldProperty(IFavoriteSchema['title'], 'Title') remote_url = property(_getRemoteURL, _setRemoteURL)
class TaxonomySettingsControlPanelAdapter(SchemaAdapterBase): adapts(IPloneSiteRoot) implements(ITaxonomySettings) def __init__(self, context): super(TaxonomySettingsControlPanelAdapter, self).__init__(context) taxonomies = ProxyFieldProperty(ITaxonomySettings['taxonomies'])
class StaticDeploymentAdapter(SchemaAdapterBase): """ Storages for particular form fields. """ section_choice = set() last_triggered = ProxyFieldProperty(IStaticDeployment['last_triggered']) delete_previous = False deployment = False
class PDFOptions(SchemaAdapterBase): implements(IPDFOptions) adapts(IPloneSiteRoot) def __init__(self, context): super(PDFOptions, self).__init__(context) self.portal = context pprop = getToolByName(self.portal, 'portal_properties') self.context = getattr(pprop, PROPERTYSHEET) self.encoding = getSiteEncoding(context) return disallowed_types = ProxyFieldProperty(IPDFOptions['disallowed_types']) recode_path = ProxyFieldProperty(IPDFOptions['recode_path']) htmldoc_path = ProxyFieldProperty(IPDFOptions['htmldoc_path']) htmldoc_options = ProxyFieldProperty(IPDFOptions['htmldoc_options']) pdfbook_logo = ProxyFieldProperty(IPDFOptions['pdfbook_logo'])
class atRealLayoutsControlPanelAdapter(SchemaAdapterBase): adapts(IPloneSiteRoot) implements(IatRealLayoutsSchema) def __init__(self, context): super(atRealLayoutsControlPanelAdapter, self).__init__(context) atreallayouts_restricted_access_anonurls = ProxyFieldProperty(IatRealLayoutsSchema['atreallayouts_restricted_access_anonurls'])
class ControlPanelAdapter(SchemaAdapterBase): adapts(IPloneSiteRoot) implements(IPlone4BioConfigurationSchema) def __init__(self, context): super(ControlPanelAdapter, self).__init__(context) self.context = getToolByName(context, 'plone4bio_dbxrefpatterns') dbxref_patterns = ProxyFieldProperty( IPlone4BioConfigurationSchema['dbxref_patterns'])
class FileSchemaAdapter(SchemaAdapterBase): """Adapter for IMutableFile. """ adapts(IMutableFile) implements(IFileSchema) def _getFile(self): return '' def _setFile(self, value): self.context.manage_upload(value) title = ProxyFieldProperty(IFileSchema['title'], 'Title', 'setTitle') language = ProxyFieldProperty(IFileSchema['language'], 'Language', 'setLanguage') description = ProxyFieldProperty(IFileSchema['description'], 'Description', 'setDescription') format = ProxyFieldProperty(IFileSchema['format'], 'Format') file = property(_getFile, _setFile)
class EventSchemaAdapter(SchemaAdapterBase): """Adapter for IMutableEvent. """ adapts(IMutableEvent) implements(IEventSchema) title = ProxyFieldProperty(IEventSchema['title'], 'Title', 'setTitle') contact_name = ProxyFieldProperty(IEventSchema['contact_name']) location = ProxyFieldProperty(IEventSchema['location']) contact_email = ProxyFieldProperty(IEventSchema['contact_email']) categories = ProxyFieldProperty(IEventSchema['categories'], 'Subject', 'setSubject') contact_phone = ProxyFieldProperty(IEventSchema['contact_phone']) event_url = ProxyFieldProperty(IEventSchema['event_url']) start_date = ProxyFieldProperty(IEventSchema['start_date'], 'start', 'setStartDate') stop_date = ProxyFieldProperty(IEventSchema['stop_date'], 'end', 'setEndDate') description = ProxyFieldProperty(IEventSchema['description'], 'Description', 'setDescription')
class EditingControlPanelAdapter(SchemaAdapterBase): implements(IEditingSchema) def __init__(self, context): super(EditingControlPanelAdapter, self).__init__(context) self.portal = getSite() pprop = getToolByName(self.portal, 'portal_properties') self.context = pprop.site_properties self.encoding = pprop.site_properties.default_charset visible_ids = ProxyFieldProperty(IEditingSchema['visible_ids']) enable_inline_editing = ProxyFieldProperty( IEditingSchema['enable_inline_editing']) enable_link_integrity_checks = ProxyFieldProperty( IEditingSchema['enable_link_integrity_checks']) ext_editor = ProxyFieldProperty(IEditingSchema['ext_editor']) default_editor = ProxyFieldProperty(IEditingSchema['default_editor']) lock_on_ttw_edit = ProxyFieldProperty(IEditingSchema['lock_on_ttw_edit'])
class SiteControlPanelAdapter(SchemaAdapterBase): def __init__(self, context): super(SiteControlPanelAdapter, self).__init__(context) self.portal = api.portal.get() self.pprop = getToolByName(context, 'portal_properties') self.context = self.pprop.site_properties self.encoding = self.pprop.site_properties.default_charset def get_site_title(self): title = getattr(self.portal, 'title', u'') return safe_unicode(title) def set_site_title(self, value): pass def get_site_title_1(self): title = getattr(self.portal, 'title_1', u'') return safe_unicode(title) def set_site_title_1(self, value): value = value or '' self.portal.title_1 = value.encode(self.encoding) title_1 = safe_unicode(self.portal.title_1) title_2 = safe_unicode(self.portal.title_2) title = u'%s %s' % (title_1, title_2) self.portal.title = title.encode(self.encoding) def get_site_title_2(self): title = getattr(self.portal, 'title_2', u'') return safe_unicode(title) def set_site_title_2(self, value): value = value or '' self.portal.title_2 = value.encode(self.encoding) title_1 = safe_unicode(self.portal.title_1) title_2 = safe_unicode(self.portal.title_2) title = u'%s %s' % (title_1, title_2) self.portal.title = title.encode(self.encoding) def get_site_orgao(self): orgao = getattr(self.portal, 'orgao', u'') return safe_unicode(orgao) def set_site_orgao(self, value): value = value or '' self.portal.orgao = value.encode(self.encoding) def get_url_orgao(self): # Define que o contexto a ser utilizado # sera a property sheet brasil_gov configs = getattr(self.pprop, 'brasil_gov', None) url_orgao = configs.getProperty('url_orgao', u'') return safe_unicode(url_orgao) def set_url_orgao(self, value): value = value or '' # Define que o contexto a ser utilizado # sera a property sheet brasil_gov configs = getattr(self.pprop, 'brasil_gov', None) configs.manage_changeProperties(url_orgao=value) def get_site_description(self): description = getattr(self.portal, 'description', u'') return safe_unicode(description) def set_site_description(self, value): if value is not None: self.portal.description = value.encode(self.encoding) else: self.portal.description = '' def get_webstats_js(self): description = getattr(self.context, 'webstats_js', u'') return safe_unicode(description) def set_webstats_js(self, value): if value is not None: self.context.webstats_js = value.encode(self.encoding) else: self.context.webstats_js = '' site_title = property(get_site_title, set_site_title) site_title_1 = property(get_site_title_1, set_site_title_1) site_title_2 = property(get_site_title_2, set_site_title_2) site_orgao = property(get_site_orgao, set_site_orgao) url_orgao = property(get_url_orgao, set_url_orgao) site_description = property(get_site_description, set_site_description) webstats_js = property(get_webstats_js, set_webstats_js) enable_sitemap = ProxyFieldProperty(ISiteSchema['enable_sitemap']) exposeDCMetaTags = ProxyFieldProperty(ISiteSchema['exposeDCMetaTags']) def get_display_pub_date_in_byline(self): return self.context.site_properties.displayPublicationDateInByline def set_display_pub_date_in_byline(self, value): self.context.site_properties.displayPublicationDateInByline = value display_pub_date_in_byline = property(get_display_pub_date_in_byline, set_display_pub_date_in_byline)