Esempio n. 1
0
class ExampleByIdForm(ViewletForm):
    """ Get example by ID."""

    label = _('examplebyidform-label', u"Display example by ID-number")

    zope.interface.implements(IViewlet)

    ignoreContext = True

    prefix = "examplebyid."

    fields = field.Fields(example_id)

    def __init__(self, context, request, view, manager):
        """ See zope.viewlet.viewlet.ViewletBase"""
        self.__parent__ = view
        self.context = context
        self.request = request
        self.manager = manager

    @button.buttonAndHandler(_(u"Display"), name='show')
    def handleShow(self, action):
        data, errors = self.extractData()
        if data['example_id'] in self.context:
            container = zope.component.getUtility(
                IExampleContainer,
                context=getSite(),
            )
            self.request.response.redirect(
                absoluteURL(container, self.request) + u"/" +
                data['example_id'])
        else:
            self.status = _('example-by-id-failure',
                            u"Example #$ID does not exist",
                            mapping={'ID': data['example_id']})
class MarkerTextCriterium(TextCriterium):
    """ Full text criterium for 'marker-fulltext' index."""

    zope.interface.implements(ICriteriumDescription)

    indexOrName = 'marker-fulltext'
    
    label = _('marker-fulltext-label', u"Marker")

    description = _('marker-fulltext-desc', u"Matches in marker field.")

    ui_weight = 30
class ProquoTextCriterium(TextCriterium):
    """ Full text criterium for 'proquo-fulltext' index."""

    zope.interface.implements(ICriteriumDescription)

    indexOrName = 'proquo-fulltext'
    
    label = _('proquo-fulltext-label', u"Denotation / Meaning")

    description = _('proquo-fulltext-desc', u"Matches in denotation or meaning field.")

    ui_weight = 20
class QuidTextCriterium(TextCriterium):
    """ Full text criterium for 'quid-fulltext' index."""

    zope.interface.implements(ICriteriumDescription)

    indexOrName = 'quid-fulltext'
    
    label = _('quid-fulltext-label', u"Example")

    description = _('quid-fulltext-desc', u"Matches in example field.")

    ui_weight = 15
class FlagsColumn(column.Column):
    """ The flags of a example."""

    header = _(u"flags")
    weight = 99999
    
    def renderCell(self, item):
        flags = zope.component.getMultiAdapter(
            (item, self.request, self.table),
            IContentProvider, name='flags')
        flags.update()
        return flags.render()
Esempio n. 6
0
class ExampleEditForm(QuotationEditForm):
    """A form to edit the example."""

    info = AddExampleInReferenceContext.info

    label = _('edit-example-label', u"Edit Example") 

    fields = field.Fields(IExample).omit(
        '__parent__', '__name__', 'reference', 'length')

    def __init__(self, context, request):
        super(QuotationEditForm, self).__init__(context, request)
        if context.source_type == 'html':
            zc.resourcelibrary.need('quotationtool.tinymce.QuotationAndExample')
Esempio n. 7
0
 def handleShow(self, action):
     data, errors = self.extractData()
     if data['example_id'] in self.context:
         container = zope.component.getUtility(
             IExampleContainer,
             context=getSite(),
         )
         self.request.response.redirect(
             absoluteURL(container, self.request) + u"/" +
             data['example_id'])
     else:
         self.status = _('example-by-id-failure',
                         u"Example #$ID does not exist",
                         mapping={'ID': data['example_id']})
Esempio n. 8
0
class AddExampleInReferenceContext(AddQuotationInReferenceContext):
    """A form for adding a quotation object to the collectanea that
    takes a reference object as context."""

    factory_name = 'quotationtool.figuresng.Example'

    label = _('add-example', u"Add a new Example")

    info = _('add-example-info', 
             u"The <span class=\"quotationtool-example-quid\">example</span> and its <span class=\"quotationtool-example-proquo\">denotation/meaning</span> have to be tagged in the quotation using the flags. If a marker is present, please tag the <span class=\"quotationtool-example-marker\">marker</span>, too.<br/>Then fill in the example, the denotation/meaning and--if present--the marker fields. The denotation/meaning field should not be used for repeating theorems most accurately, but for the term that is in question. The same with the example field. The input data should serve searching the database but not hermeneutics. If you would like to give more accurate information then please write a comment after submitting the form."
             )
    
    fields = field.Fields(IExample).omit(
        '__parent__', '__name__', 'reference', 'length')#, 'source_type')

    def __init__(self, context, request):
        super(AddQuotationInReferenceContext, self).__init__(context, request)
        zc.resourcelibrary.need('quotationtool.tinymce.QuotationAndExample')

    def add(self, example):
        container = zope.component.getUtility(
            IExampleContainer, context=self.context)
        name = INameChooser(container).chooseName(example, None)
        self._obj = container[name] = example
Esempio n. 9
0
 def __call__(self):
     return _('examplecontainer-labelview', u"Examples")
Esempio n. 10
0
 def __call__(self):
     return _('example-labelview',
              u"Example #$ID",
              mapping={'ID': self.context.__name__})
Esempio n. 11
0
from zope.viewlet.manager import ViewletManager, WeightOrderedViewletManager
from zope.contentprovider.interfaces import IContentProvider

from quotationtool.figuresng.interfaces import _, IExampleContainer


class IExampleContainerAdds(IViewletManager):
    """ A viewlet manager for adds on the container view."""


ExampleContainerAdds = ViewletManager('examplecontainer-adds',
                                      IExampleContainerAdds,
                                      bases=(WeightOrderedViewletManager, ))

example_id = zope.schema.TextLine(
    title=_('exampleid-field-title', u"ID"),
    required=False,
)
example_id.__name__ = 'example_id'


class ExampleByIdForm(ViewletForm):
    """ Get example by ID."""

    label = _('examplebyidform-label', u"Display example by ID-number")

    zope.interface.implements(IViewlet)

    ignoreContext = True

    prefix = "examplebyid."
    first_criterium_connector_name = CONNECTOR_OR

    ignore_empty_criteria = True

    def resultURL(self, context, request):
        examples = zope.component.getUtility(
            IExampleContainer,
            context=context)
        return absoluteURL(examples, request) + u"/@@searchResult.html"

    session_name = 'examples'


example_search_filter_factory = zope.component.factory.Factory(
    ExampleSearchFilter,
    _('ExampleSearchFilter-title', u"Examples"),
    _('ExampleSearchFilter-desc', u"Search for examples.")
    )


class QuidTextCriterium(TextCriterium):
    """ Full text criterium for 'quid-fulltext' index."""

    zope.interface.implements(ICriteriumDescription)

    indexOrName = 'quid-fulltext'
    
    label = _('quid-fulltext-label', u"Example")

    description = _('quid-fulltext-desc', u"Matches in example field.")