14 |
14 |
15 from zope.interface import Interface |
15 from zope.interface import Interface |
16 |
16 |
17 from pyams_content.interfaces import IBaseContent |
17 from pyams_content.interfaces import IBaseContent |
18 from pyams_content.shared.common import ISharedContent |
18 from pyams_content.shared.common import ISharedContent |
19 from pyams_default_theme.interfaces import IContentNavigationTitle |
|
20 from pyams_content.shared.site import ISiteElementNavigation |
19 from pyams_content.shared.site import ISiteElementNavigation |
|
20 from pyams_default_theme.interfaces import IContentHeader, IContentNavigationTitle |
21 from pyams_i18n.interfaces import II18n |
21 from pyams_i18n.interfaces import II18n |
|
22 from pyams_sequence.interfaces import IInternalReference |
22 from pyams_skin.layer import IPyAMSUserLayer |
23 from pyams_skin.layer import IPyAMSUserLayer |
23 from pyams_utils.adapter import ContextRequestAdapter, ContextRequestViewAdapter, adapter_config |
24 from pyams_utils.adapter import ContextRequestAdapter, ContextRequestViewAdapter, adapter_config |
24 from pyams_utils.interfaces.tales import ITALESExtension |
25 from pyams_utils.interfaces.tales import ITALESExtension |
25 from pyams_workflow.interfaces import IWorkflowPublicationInfo |
26 from pyams_workflow.interfaces import IWorkflowPublicationInfo |
26 |
27 |
27 |
28 |
28 @adapter_config(context=(IBaseContent, IPyAMSUserLayer), provides=IContentNavigationTitle) |
29 @adapter_config(context=(IBaseContent, IPyAMSUserLayer), |
|
30 provides=IContentNavigationTitle) |
29 def shared_content_navigation_title(context, request): |
31 def shared_content_navigation_title(context, request): |
30 """Default content navigation title adapter""" |
32 """Default content navigation title adapter""" |
31 return II18n(context).query_attribute('title', request=request) |
33 return II18n(context).query_attribute('title', request=request) |
|
34 |
|
35 |
|
36 @adapter_config(context=(IInternalReference, IPyAMSUserLayer), |
|
37 provides=IContentNavigationTitle) |
|
38 def internal_link_content_navigation_title(context, request): |
|
39 """Internal link content navigation title adapter""" |
|
40 registry = request.registry |
|
41 return registry.queryMultiAdapter((context.target, request), IContentNavigationTitle) |
32 |
42 |
33 |
43 |
34 @adapter_config(name='pyams_title', |
44 @adapter_config(name='pyams_title', |
35 context=(Interface, Interface, Interface), |
45 context=(Interface, Interface, Interface), |
36 provides=ITALESExtension) |
46 provides=ITALESExtension) |
38 """PyAMS content title TALES extension""" |
48 """PyAMS content title TALES extension""" |
39 |
49 |
40 def render(self, context=None): |
50 def render(self, context=None): |
41 if context is None: |
51 if context is None: |
42 context = self.context |
52 context = self.context |
43 return self.request.registry.queryMultiAdapter((context, self.request), IContentNavigationTitle) |
53 return self.request.registry.queryMultiAdapter((context, self.request), |
|
54 IContentNavigationTitle) |
44 |
55 |
45 |
56 |
46 @adapter_config(context=(ISharedContent, IPyAMSUserLayer), provides=ISiteElementNavigation) |
57 @adapter_config(name='pyams_header', |
|
58 context=(Interface, Interface, Interface), |
|
59 provides=ITALESExtension) |
|
60 class PyAMSContentHeaderTALESExtension(ContextRequestViewAdapter): |
|
61 """PyAMS content header TALES extension""" |
|
62 |
|
63 def render(self, context=None): |
|
64 if context is None: |
|
65 context = self.context |
|
66 return self.request.registry.queryMultiAdapter((context, self.request), |
|
67 IContentHeader) |
|
68 |
|
69 |
|
70 @adapter_config(context=(ISharedContent, IPyAMSUserLayer), |
|
71 provides=ISiteElementNavigation) |
47 class SharedContentNavigationAdapter(ContextRequestAdapter): |
72 class SharedContentNavigationAdapter(ContextRequestAdapter): |
48 """Shared content navigation adapter""" |
73 """Shared content navigation adapter""" |
49 |
74 |
50 @property |
75 @property |
51 def visible(self): |
76 def visible(self): |