Exemplo n.º 1
0
    def update_links(self, source, target):
        super(TurningFooterTable, self).update_links(source, target)

        base = self.get_canonical_path()
        resources_new2old = get_context().database.resources_new2old
        base = str(base)
        old_base = resources_new2old.get(base, base)
        old_base = Path(old_base)
        new_base = Path(base)

        # languages
        site_root = self.get_site_root()
        available_languages = site_root.get_property('website_languages')

        # Append links contained in data
        handler = self.handler
        get_value = handler.get_record_value

        for record in handler.get_records_in_order():
            for language in available_languages:
                data = get_value(record, 'data', language=language)
                if data is None:
                    continue
                events = _change_link(source, target, old_base, new_base,
                                      data)
                events = list(events)
                p_events = Property(events, language=language)
                # TODO Update all language in one time
                self.update_record(record.id, **{'data': p_events})
        get_context().database.change_resource(self)
Exemplo n.º 2
0
    def update_links(self, source, target):
        super(FooterMenu, self).update_links(source, target)

        base = self.get_canonical_path()
        site_root = self.get_site_root()
        available_languages = site_root.get_property("website_languages")
        resources_new2old = get_context().database.resources_new2old
        base = str(base)
        old_base = resources_new2old.get(base, base)
        old_base = Path(old_base)
        new_base = Path(base)
        handler = self.handler
        get_value = handler.get_record_value

        for record in handler.get_records_in_order():
            properties = []
            for language in available_languages:
                html_content = get_value(record, "html_content", language=language)
                if html_content is None:
                    continue
                events = _change_link(source, target, old_base, new_base, html_content)
                events = list(events)
                properties.append(Property(events, language=language))
            self.update_record(record.id, **{"html_content": properties})
        get_context().database.change_resource(self)
Exemplo n.º 3
0
    def update_links(self, source, target):
        base = self.get_canonical_path()
        resources_new2old = get_context().database.resources_new2old
        base = str(base)
        old_base = resources_new2old.get(base, base)
        old_base = Path(old_base)
        new_base = Path(base)

        site_root = self.get_site_root()
        languages = site_root.get_property('website_languages')
        links = []
        for key, datatype in self.get_metadata_schema().items():
            multilingual = getattr(datatype, 'multilingual', False)
            langs = languages if multilingual is True else [None]
            if issubclass(datatype, XHTMLBody):
                for lang in langs:
                    events = self.get_property(key, language=lang)
                    if not events:
                        continue
                    events = _change_link(source, target, old_base, new_base,
                                          events)
                    events = list(events)
                    self.set_property(key, events, language=lang)
            elif issubclass(datatype, PathDataType):
                # Relative path
                for lang in langs:
                    path = self.get_property(key, language=lang)
                    if path is None:
                        continue
                    path = str(old_base.resolve2(path))
                    if path == source:
                        # Hit the old name
                        new_path = str(new_base.get_pathto(target))
                        self.set_property(key, new_path, language=lang)
            elif issubclass(datatype, AbsolutePathDataTypeEnumerate):
                # Absolute path
                for lang in langs:
                    path = self.get_property(key, language=lang)
                    if path is None:
                        continue
                    path = str(path)
                    path = resources_new2old.get(path, path)
                    if path == source:
                        # Hit the old name
                        self.set_property(key, str(target), language=lang)
        # Tagaware ?
        if isinstance(self, TagsAware):
            TagsAware.update_links(self, source, target)

        # Change resource
        get_context().database.change_resource(self)