16 # import standard library |
16 # import standard library |
17 from persistent import Persistent |
17 from persistent import Persistent |
18 from persistent.mapping import PersistentMapping |
18 from persistent.mapping import PersistentMapping |
19 |
19 |
20 # import interfaces |
20 # import interfaces |
|
21 from pyams_content.component.extfile.interfaces import IExtFileContainerTarget |
21 from pyams_content.component.links.interfaces import ILinkContainerTarget |
22 from pyams_content.component.links.interfaces import ILinkContainerTarget |
22 from pyams_content.shared.imagemap.interfaces import IMAGEMAP_CONTENT_TYPE, IMAGEMAP_CONTENT_NAME, \ |
23 from pyams_content.shared.imagemap.interfaces import IMAGEMAP_CONTENT_TYPE, IMAGEMAP_CONTENT_NAME, \ |
23 IWfImageMap, IImageMap, IImageMapArea |
24 IWfImageMap, IImageMap, IImageMapArea |
|
25 from z3c.form.interfaces import NOT_CHANGED |
24 from zope.location.interfaces import ISublocations |
26 from zope.location.interfaces import ISublocations |
25 from zope.traversing.interfaces import ITraversable |
27 from zope.traversing.interfaces import ITraversable |
26 |
28 |
27 # import packages |
29 # import packages |
28 from pyams_content.shared.common import WfSharedContent, register_content_type, SharedContent |
30 from pyams_content.shared.common import WfSharedContent, register_content_type, SharedContent |
43 title = FieldProperty(IImageMapArea['title']) |
45 title = FieldProperty(IImageMapArea['title']) |
44 link = FieldProperty(IImageMapArea['link']) |
46 link = FieldProperty(IImageMapArea['link']) |
45 area = FieldProperty(IImageMapArea['area']) |
47 area = FieldProperty(IImageMapArea['area']) |
46 |
48 |
47 |
49 |
48 @implementer(IWfImageMap, ILinkContainerTarget) |
50 @implementer(IWfImageMap, IExtFileContainerTarget, ILinkContainerTarget) |
49 class WfImageMap(WfSharedContent): |
51 class WfImageMap(WfSharedContent): |
50 """Base image map""" |
52 """Base image map""" |
51 |
53 |
52 content_type = IMAGEMAP_CONTENT_TYPE |
54 content_type = IMAGEMAP_CONTENT_TYPE |
53 content_name = IMAGEMAP_CONTENT_NAME |
55 content_name = IMAGEMAP_CONTENT_NAME |
64 def image(self): |
66 def image(self): |
65 return self._image |
67 return self._image |
66 |
68 |
67 @image.setter |
69 @image.setter |
68 def image(self, value): |
70 def image(self, value): |
|
71 if value: |
|
72 for image in value.values(): |
|
73 if image and (image is not NOT_CHANGED): |
|
74 self.areas = PersistentMapping() |
|
75 break |
69 self._image = value |
76 self._image = value |
70 if value: |
|
71 self.areas = PersistentMapping() |
|
72 |
77 |
73 def add_area(self, area): |
78 def add_area(self, area): |
74 self._index += 1 |
79 self._index += 1 |
75 key = str(self._index) |
80 key = str(self._index) |
76 self.areas[key] = area |
81 self.areas[key] = area |