Changeset 1902 in products


Ignore:
Timestamp:
Mar 12, 2010 2:56:13 PM (14 years ago)
Author:
mylan
Message:

#167: Added custom_script, fields, stop_words into ISEOConfigletSchema and appropriate adataer and configlet form

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.seoptimizer/branches/refactoring2.3.0/quintagroup/seoptimizer/browser/seo_configlet.py

    r1884 r1902  
    66from zope.schema.vocabulary import SimpleVocabulary 
    77from zope.schema import Bool, Text, Choice, Tuple, List 
     8from zope.schema import SourceText 
    89from zope.app.form.browser import RadioWidget 
    910 
     
    1617 
    1718from Products.CMFCore.utils import getToolByName 
     19from Products.CMFPlone.utils import safe_unicode 
    1820from Products.CMFDefault.formlib.schema import ProxyFieldProperty 
    1921from Products.CMFDefault.formlib.schema import SchemaAdapterBase 
     
    6466        required=False) 
    6567 
     68    custom_script = SourceText( 
     69        title=_("label_custom_script", default=u'Header JavaScript'), 
     70        description=_("help_custom_script", 
     71                default=u"This JavaScript code will be included in " 
     72                         "the rendered HTML as entered in the page header."), 
     73        default=u'', 
     74        required=False) 
     75 
     76    fields = List( 
     77        title=_("label_fields", default='Fields for keywords statistic calculation.'), 
     78        description=_("help_fields", 
     79                default='Fill in filds (one per line) which statistics of keywords usage' 
     80                    'should be calculated for.'), 
     81        required=False) 
     82 
     83    stop_words = List( 
     84        title=_("label_stop_words", default='Stop words.'), 
     85        description=_("help_stop_words", 
     86                default='Fill in stop words (one per line) which will ' 
     87                    'be excluded from kewords statistics calculation.'), 
     88        required=False) 
    6689 
    6790class SEOConfigletAdapter(SchemaAdapterBase): 
     
    92115        self.context._updateProperty('content_types_with_seoproperties', value) 
    93116 
     117    def getCustomScript(self): 
     118        description = getattr(self.context, 'custom_script', u'') 
     119        return safe_unicode(description) 
     120 
     121    def setCustomScript(self, value): 
     122        if value is not None: 
     123            self.context.custom_script = value.encode(self.encoding) 
     124        else: 
     125            self.context.custom_script = '' 
    94126 
    95127    exposeDCMetaTags = property(getExposeDC, setExposeDC) 
     
    97129    metatags_order = ProxyFieldProperty(ISEOConfigletSchema['metatags_order']) 
    98130    types_seo_enabled = property(getTypesSEOEnabled, setTypesSEOEnabled) 
     131    custom_script = property(getCustomScript, setCustomScript) 
     132    fields = ProxyFieldProperty(ISEOConfigletSchema['fields']) 
     133    stop_words = ProxyFieldProperty(ISEOConfigletSchema['stop_words']) 
    99134 
    100135 
    101 class SmallTextAreaWidget(TextAreaWidget): 
     136class Text2ListWidget(TextAreaWidget): 
    102137    height = 5 
    103138    splitter = re.compile(u'\\r?\\n', re.S|re.U) 
     
    119154 
    120155    form_fields = FormFields(ISEOConfigletSchema) 
    121     form_fields['default_custom_metatags'].custom_widget = SmallTextAreaWidget 
    122     form_fields['metatags_order'].custom_widget = SmallTextAreaWidget 
     156    form_fields['default_custom_metatags'].custom_widget = Text2ListWidget 
     157    form_fields['metatags_order'].custom_widget = Text2ListWidget 
    123158    form_fields['types_seo_enabled'].custom_widget = MultiCheckBoxThreeColumnWidget 
    124159    form_fields['types_seo_enabled'].custom_widget.cssClass='label' 
     160    form_fields['fields'].custom_widget = Text2ListWidget 
     161    form_fields['stop_words'].custom_widget = Text2ListWidget 
    125162 
    126163    label = _("Search Engine Optimizer configuration") 
Note: See TracChangeset for help on using the changeset viewer.