web/views/basecomponents.py
changeset 3377 dd9d292b6a6d
parent 3185 bd0126d17e83
child 3407 da9cc8cc7c5f
equal deleted inserted replaced
3376:f5c69485381f 3377:dd9d292b6a6d
    27                         help=_('display the component or not')),
    27                         help=_('display the component or not')),
    28     }
    28     }
    29 
    29 
    30 class RQLInputForm(component.Component):
    30 class RQLInputForm(component.Component):
    31     """build the rql input form, usually displayed in the header"""
    31     """build the rql input form, usually displayed in the header"""
    32     id = 'rqlinput'
    32     __regid__ = 'rqlinput'
    33     cw_property_defs = VISIBLE_PROP_DEF
    33     cw_property_defs = VISIBLE_PROP_DEF
    34     visible = False
    34     visible = False
    35 
    35 
    36     def call(self, view=None):
    36     def call(self, view=None):
    37         if hasattr(view, 'filter_box_context_info'):
    37         if hasattr(view, 'filter_box_context_info'):
    57         self.w(u'</form></div>')
    57         self.w(u'</form></div>')
    58 
    58 
    59 
    59 
    60 class ApplLogo(component.Component):
    60 class ApplLogo(component.Component):
    61     """build the instance logo, usually displayed in the header"""
    61     """build the instance logo, usually displayed in the header"""
    62     id = 'logo'
    62     __regid__ = 'logo'
    63     cw_property_defs = VISIBLE_PROP_DEF
    63     cw_property_defs = VISIBLE_PROP_DEF
    64     # don't want user to hide this component using an cwproperty
    64     # don't want user to hide this component using an cwproperty
    65     site_wide = True
    65     site_wide = True
    66 
    66 
    67     def call(self):
    67     def call(self):
    69                % (self.req.base_url(), self.req.external_resource('LOGO')))
    69                % (self.req.base_url(), self.req.external_resource('LOGO')))
    70 
    70 
    71 
    71 
    72 class ApplHelp(component.Component):
    72 class ApplHelp(component.Component):
    73     """build the help button, usually displayed in the header"""
    73     """build the help button, usually displayed in the header"""
    74     id = 'help'
    74     __regid__ = 'help'
    75     cw_property_defs = VISIBLE_PROP_DEF
    75     cw_property_defs = VISIBLE_PROP_DEF
    76     def call(self):
    76     def call(self):
    77         self.w(u'<a href="%s" class="help" title="%s">&#160;</a>'
    77         self.w(u'<a href="%s" class="help" title="%s">&#160;</a>'
    78                % (self.build_url(_restpath='doc/main'),
    78                % (self.build_url(_restpath='doc/main'),
    79                   self.req._(u'help'),))
    79                   self.req._(u'help'),))
    84     else a link to the connected user object with a loggout link
    84     else a link to the connected user object with a loggout link
    85     """
    85     """
    86     cw_property_defs = VISIBLE_PROP_DEF
    86     cw_property_defs = VISIBLE_PROP_DEF
    87     # don't want user to hide this component using an cwproperty
    87     # don't want user to hide this component using an cwproperty
    88     site_wide = True
    88     site_wide = True
    89     id = 'loggeduserlink'
    89     __regid__ = 'loggeduserlink'
    90 
    90 
    91     def call(self):
    91     def call(self):
    92         if not self.req.cnx.anonymous_connection:
    92         if not self.req.cnx.anonymous_connection:
    93             # display useractions and siteactions
    93             # display useractions and siteactions
    94             actions = self.vreg['actions'].possible_actions(self.req, rset=self.rset)
    94             actions = self.vreg['actions'].possible_actions(self.req, rset=self.rset)
   121 class ApplicationMessage(component.Component):
   121 class ApplicationMessage(component.Component):
   122     """display messages given using the __message parameter into a special div
   122     """display messages given using the __message parameter into a special div
   123     section
   123     section
   124     """
   124     """
   125     __select__ = yes()
   125     __select__ = yes()
   126     id = 'applmessages'
   126     __regid__ = 'applmessages'
   127     # don't want user to hide this component using an cwproperty
   127     # don't want user to hide this component using an cwproperty
   128     cw_property_defs = {}
   128     cw_property_defs = {}
   129 
   129 
   130     def call(self):
   130     def call(self):
   131         msgs = [msg for msg in (self.req.get_shared_data('sources_error', pop=True),
   131         msgs = [msg for msg in (self.req.get_shared_data('sources_error', pop=True),
   138         self.w(u'</div>')
   138         self.w(u'</div>')
   139 
   139 
   140 
   140 
   141 class ApplicationName(component.Component):
   141 class ApplicationName(component.Component):
   142     """display the instance name"""
   142     """display the instance name"""
   143     id = 'appliname'
   143     __regid__ = 'appliname'
   144     cw_property_defs = VISIBLE_PROP_DEF
   144     cw_property_defs = VISIBLE_PROP_DEF
   145     # don't want user to hide this component using an cwproperty
   145     # don't want user to hide this component using an cwproperty
   146     site_wide = True
   146     site_wide = True
   147 
   147 
   148     def call(self):
   148     def call(self):
   152                 self.req.base_url(), xml_escape(title)))
   152                 self.req.base_url(), xml_escape(title)))
   153 
   153 
   154 
   154 
   155 class SeeAlsoVComponent(component.RelatedObjectsVComponent):
   155 class SeeAlsoVComponent(component.RelatedObjectsVComponent):
   156     """display any entity's see also"""
   156     """display any entity's see also"""
   157     id = 'seealso'
   157     __regid__ = 'seealso'
   158     context = 'navcontentbottom'
   158     context = 'navcontentbottom'
   159     rtype = 'see_also'
   159     rtype = 'see_also'
   160     role = 'subject'
   160     role = 'subject'
   161     order = 40
   161     order = 40
   162     # register msg not generated since no entity use see_also in cubicweb itself
   162     # register msg not generated since no entity use see_also in cubicweb itself
   166 
   166 
   167 class EtypeRestrictionComponent(component.Component):
   167 class EtypeRestrictionComponent(component.Component):
   168     """displays the list of entity types contained in the resultset
   168     """displays the list of entity types contained in the resultset
   169     to be able to filter accordingly.
   169     to be able to filter accordingly.
   170     """
   170     """
   171     id = 'etypenavigation'
   171     __regid__ = 'etypenavigation'
   172     __select__ = two_etypes_rset() | match_form_params('__restrtype', '__restrtypes',
   172     __select__ = two_etypes_rset() | match_form_params('__restrtype', '__restrtypes',
   173                                                        '__restrrql')
   173                                                        '__restrrql')
   174     cw_property_defs = VISIBLE_PROP_DEF
   174     cw_property_defs = VISIBLE_PROP_DEF
   175     # don't want user to hide this component using an cwproperty
   175     # don't want user to hide this component using an cwproperty
   176     site_wide = True
   176     site_wide = True
   214             html.insert(0, u'<span class="selected">%s</span>' % _('Any'))
   214             html.insert(0, u'<span class="selected">%s</span>' % _('Any'))
   215         self.w(u'&#160;|&#160;'.join(html))
   215         self.w(u'&#160;|&#160;'.join(html))
   216         self.w(u'</div>')
   216         self.w(u'</div>')
   217 
   217 
   218 class PdfViewComponent(component.Component):
   218 class PdfViewComponent(component.Component):
   219     id = 'pdfview'
   219     __regid__ = 'pdfview'
   220     __select__ = yes()
   220     __select__ = yes()
   221 
   221 
   222     context = 'header'
   222     context = 'header'
   223     property_defs = {
   223     property_defs = {
   224         _('visible'):  dict(type='Boolean', default=True,
   224         _('visible'):  dict(type='Boolean', default=True,