예제 #1
0
파일: skin.py 프로젝트: nicolasderam/shop
 def get_styles(self, context):
     styles = Skin.get_styles(self, context)
     styles.extend(self.base_styles)
     styles.append(
         '/ui/common/js/jquery.multiselect2side/css/jquery.multiselect2side.css'
     )
     styles.append('/ui/common/js/fancybox/jquery.fancybox-1.3.1.css')
     return styles
예제 #2
0
파일: skin.py 프로젝트: nicolasderam/shop
 def get_scripts(self, context):
     scripts = Skin.get_scripts(self, context)
     scripts.append('/ui/common/js/javascript.js')
     scripts.append(
         '/ui/common/js/jquery.multiselect2side/js/jquery.multiselect2side.js'
     )
     scripts.append('/ui/common/js/fancybox/jquery.fancybox-1.3.1.pack.js')
     return scripts
예제 #3
0
파일: skin.py 프로젝트: nkhine/ztm-ikaaro
 def get_scripts(self, context):
     scripts = BaseSkin.get_scripts(self, context)
     # In edition mode we add fancybox script
     edit_mode = is_navigation_mode(context) is False
     ac = context.resource.get_access_control()
     is_admin = ac.is_allowed_to_edit(context.user, context.resource)
     if edit_mode is True or is_admin:
         scripts.append("/ui/common/js/fancybox/jquery.fancybox-1.3.1.pack.js")
     scripts.append("/ui/common/js/javascript.js")
     scripts.append("/ui/common/js/jquery.multiselect2side/javascript.js")
     # Do not had a scritp several times
     single_sripts = []
     for script in scripts:
         if script not in single_sripts:
             single_sripts.append(script)
     return single_sripts
예제 #4
0
파일: skins.py 프로젝트: hforge/hforge
    def build_namespace(self, context):
        namespace = BaseSkin.build_namespace(self, context)
        namespace['column'] = None
        if context.user is None:
            namespace['location'].tabs = None

        # Right Column
        resource = context.resource
        if resource is not resource.get_site_root():
            return namespace

        if context.view is not resource.get_view(None):
            return namespace

        try:
            column = resource.get_resource('columnright')
        except LookupError:
            return namespace

        namespace['column'] = column.get_handler().events
        return namespace
예제 #5
0
파일: skin.py 프로젝트: hforge/itws
 def get_styles(self, context):
     styles = BaseSkin.get_styles(self, context)
     if styles.count('/ui/aruni/aruni.css'):
         styles.remove('/ui/aruni/aruni.css')
     # insert common style after bo.css
     styles.insert(1, '/ui/common/style.css')
     if self.add_common_nav_css:
         styles.append('/ui/common/menu.css')
     styles.append('/ui/common/js/jquery.multiselect2side/style.css')
     # In edition mode we add fancybox css
     edit_mode = is_navigation_mode(context) is False
     ac = context.resource.get_access_control()
     is_admin = ac.is_allowed_to_edit(context.user, context.resource)
     if edit_mode is True or is_admin:
         styles.append('/ui/common/js/fancybox/jquery.fancybox-1.3.1.css')
         styles.append('/ui/common/bo.css')
     # Do not had a style several times
     # Do not tweak cascading by calling reversed before and after
     single_styles = []
     for style in reversed(styles):
         if style not in single_styles:
             single_styles.append(style)
     return list(reversed(single_styles))
예제 #6
0
파일: skin.py 프로젝트: hforge/shop
 def get_scripts(self, context):
     scripts = Skin.get_scripts(self, context)
     scripts.append('/ui/common/js/javascript.js')
     scripts.append('/ui/common/js/jquery.multiselect2side/js/jquery.multiselect2side.js')
     scripts.append('/ui/common/js/fancybox/jquery.fancybox-1.3.1.pack.js')
     return scripts
예제 #7
0
파일: skin.py 프로젝트: hforge/shop
 def get_styles(self, context):
     styles = Skin.get_styles(self, context)
     styles.extend(self.base_styles)
     styles.append('/ui/common/js/jquery.multiselect2side/css/jquery.multiselect2side.css')
     styles.append('/ui/common/js/fancybox/jquery.fancybox-1.3.1.css')
     return styles
예제 #8
0
파일: skins.py 프로젝트: TZM/zmgc
 def build_namespace(self, context):
     namespace = merge_dicts(BaseSkin.build_namespace(self, context), {
     'upper_footer': self.upper_footer(context=context),
     })
     #print namespace
     return namespace
예제 #9
0
파일: skin.py 프로젝트: nicolasderam/shop
                return sidebar
            return site_root.get_resource('category-sidebar')
        return NeutralSkin.get_sidebar_resource(self, context)

    # Lazy (dynamic property)
    def get_lazy_current_category(self, context):
        here = context.resource
        shop = get_shop(here)
        here = context.resource
        if isinstance(here, shop.category_class):
            return here.get_title()
        elif isinstance(here, shop.product_class):
            return here.parent.get_title()
        return None


###########################################################################
# Register
###########################################################################
path = get_abspath('ui/shop/')
register_skin('shop', ShopSkin(path))

path = get_abspath('ui/backoffice/')
register_skin('backoffice', BackofficeSkin(path))

path = get_abspath('ui/modules/')
register_skin('modules', Skin(path))

path = get_abspath('ui/default_skin/')
register_skin('default_skin', ShopSkin(path))
예제 #10
0
파일: skin.py 프로젝트: hforge/itws
 def build_namespace(self, context):
     return merge_dicts(BaseSkin.build_namespace(self, context),
               title=context.view.get_title(context),
               context_menus=list(self._get_context_menus(context)))
예제 #11
0
파일: skin.py 프로젝트: hforge/itws
 def get_scripts(self, context):
     scripts = BaseSkin.get_scripts(self, context)
     scripts.append('/ui/common/js/jquery.multiselect2side/javascript.js')
     return scripts
예제 #12
0
파일: skin.py 프로젝트: hforge/itws
 def get_styles(self, context):
     styles = BaseSkin.get_styles(self, context)
     styles.append('/ui/common/js/jquery.multiselect2side/style.css')
     styles.remove('/theme/style/;download')
     return styles
예제 #13
0
파일: skin.py 프로젝트: hforge/itws
    def build_namespace(self, context):
        namespace = BaseSkin.build_namespace(self, context)

        here = context.resource
        here_ac = here.get_access_control()
        site_root = context.site_root
        theme = site_root.get_resource('theme')
        # banner namespace
        banner_ns = {}
        banner_ns['title'] = theme.get_property('banner_title')
        banner_ns['description'] = site_root.get_property('description')
        banner_path = None
        path = theme.get_property('banner_path')
        if path:
            banner = theme.get_resource(path, soft=True)
            if banner:
                ac = banner.get_access_control()
                if ac.is_allowed_to_view(context.user, banner):
                    banner_path = context.get_link(banner)
        banner_ns['path'] = banner_path
        namespace['banner'] = banner_ns

        # Site search
        text = context.get_form_value('text', type=Unicode)
        namespace['text'] = text.strip()

        # Specific class based on the current resource format
        class_id = getattr(here, 'class_id', None)
        if class_id:
            class_id = class_id.replace('/', '-slash-')
            view_name = context.view_name or here.get_default_view_name()
            page_css_class = '%s-%s' % (class_id, view_name)
            page_css_class = page_css_class.replace('_', '-')
            namespace['page_css_class'] = page_css_class.lower()
            # resources classes
            resource_classes = []
            r = here
            while not isinstance(r, type(site_root)):
                resource_classes.append(r)
                r = r.parent
            resource_classes = [ r.name for r in reversed(resource_classes) ]
            namespace['resource_class'] = ' '.join(resource_classes)
        else:
            namespace['page_css_class'] = None
            namespace['resource_class'] = None

        # Add custom data inside the template
        custom_data = theme.get_property('custom_data') or ''
        namespace['custom_data'] = XMLParser(custom_data)

        # RSS Feeds title
        namespace['rss_feeds'] = self.get_rss_feeds(context)

        # Turning footer
        turning_footer = site_root.get_resource('theme/turning-footer',
                                                soft=True)
        if turning_footer:
            view = turning_footer.view
            namespace['turning_footer'] = view.GET(turning_footer, context)
        else:
            namespace['turning_footer'] = None

        # backoffice class
        namespace['bo_class'] = self.get_backoffice_class(context)

        # Readonly
        body_css = None
        if here_ac.is_allowed_to_edit(context.user, here) \
                and type(context.database) is ROGitDatabase:
            body_css = 'readonly'
        namespace['body_css'] = body_css

        # Sidebar
        sidebar = None
        display_sidebar = (getattr(here, 'display_sidebar', True)
                and getattr(context.view, 'display_sidebar', True))
        if display_sidebar and here_ac.is_allowed_to_view(context.user, here):
            sidebar_resource = self.get_sidebar_resource(context)
            if sidebar_resource:
                order_name = sidebar_resource.sidebar_name
                sidebar_view = SideBar_View(order_name=order_name)
                if not sidebar_view.is_empty(sidebar_resource, context):
                    # Heuristic, do not compute sidebar view
                    # if there is no items
                    sidebar = sidebar_view.GET(sidebar_resource, context)

        namespace['sidebar_view'] = sidebar
        namespace['sidebar'] = sidebar or namespace['context_menus']

        # Language
        ws_languages = site_root.get_property('website_languages')
        accept = context.accept_language
        namespace['lang'] = accept.select_language(ws_languages)

        # Nav
        # If there is no template specify we simply return the namespace
        nav = self.build_nav_namespace(context)
        namespace['nav'] = nav
        namespace['nav_length'] = len(nav['items'])
        nav_template = self.nav_data['template']
        if nav_template is not None:
            nav_template = self.get_resource(nav_template)
            namespace['nav'] = stl(nav_template, {'items': nav['items']})

        # Footer
        namespace['footer'] = None
        footer_template = self.footer_data['template']
        if footer_template is not None:
            ns_footer = self.build_footer_namespace(context)
            footer = None
            if len(ns_footer['items']):
                footer_template = self.get_resource(footer_template)
                footer = stl(footer_template, ns_footer)
            namespace['footer'] = footer

        # Hide context menus if no user authenticated
        if context.user is None:
            namespace['context_menus'] = []

        # Allow to hide the menu if there is only one item
        namespace['display_menu'] = (namespace['nav_length'] > 1)

        # Admin bar
        site_root = context.site_root
        site_root_ac = site_root.get_access_control()
        if site_root_ac.is_allowed_to_edit(context.user, site_root):
            namespace['admin_bar'] = AdminBarTemplate(context=context)
        else:
            namespace['admin_bar'] = None
        return namespace
예제 #14
0
파일: skin.py 프로젝트: nkhine/ztm-ikaaro
    def build_namespace(self, context):
        namespace = BaseSkin.build_namespace(self, context)
        here = context.resource
        here_ac = here.get_access_control()
        site_root = context.site_root
        theme = site_root.get_resource("theme")
        # banner namespace
        banner_ns = {}
        banner_ns["title"] = theme.get_property("banner_title")
        banner_ns["description"] = site_root.get_property("description")
        banner_path = None
        path = theme.get_property("banner_path")
        if path:
            banner = theme.get_resource(path, soft=True)
            if banner:
                ac = banner.get_access_control()
                if ac.is_allowed_to_view(context.user, banner):
                    banner_path = context.get_link(banner)
        banner_ns["path"] = banner_path
        namespace["banner"] = banner_ns

        # Site search
        text = context.get_form_value("search_text", type=Unicode)
        namespace["text"] = text.strip()

        # Specific class based on the current resource format
        class_id = getattr(here, "class_id", None)
        if class_id:
            class_id = class_id.replace("/", "-slash-")
            view_name = context.view_name or here.get_default_view_name()
            page_css_class = "%s-%s" % (class_id, view_name)
            page_css_class = page_css_class.replace("_", "-")
            namespace["page_css_class"] = page_css_class.lower()
            # resources classes
            resource_classes = []
            r = here
            while not isinstance(r, type(site_root)):
                resource_classes.append(r)
                r = r.parent
            resource_classes = [r.name for r in reversed(resource_classes)]
            namespace["resource_class"] = " ".join(resource_classes)
        else:
            namespace["page_css_class"] = None
            namespace["resource_class"] = None

        # Add custom data inside the template
        custom_data = theme.get_property("custom_data") or ""
        namespace["custom_data"] = XMLParser(custom_data)

        # RSS Feeds title
        namespace["rss_feeds"] = self.get_rss_feeds(context)

        # Turning footer
        turning_footer = site_root.get_resource("theme/turning-footer", soft=True)
        if turning_footer:
            view = turning_footer.view
            namespace["turning_footer"] = view.GET(turning_footer, context)
        else:
            namespace["turning_footer"] = None

        # backoffice class
        namespace["bo_class"] = self.get_backoffice_class(context)

        # Readonly
        body_css = None
        if here_ac.is_allowed_to_edit(context.user, here) and type(context.database) is ROGitDatabase:
            body_css = "readonly"
        namespace["body_css"] = body_css

        # Sidebar
        sidebar = None
        nacfsv = tuple(not_allowed_cls_for_sidebar_view)
        is_allowed_cls = not isinstance(here, nacfsv)
        if is_allowed_cls:
            iasocv = self.is_allowed_sidebar_on_current_view(context)
            if iasocv:
                sidebar_resource = self.get_sidebar_resource(context)
                if sidebar_resource:
                    order_name = sidebar_resource.sidebar_name
                    sidebar_view = SideBar_View(order_name=order_name)
                    if not sidebar_view.is_empty(sidebar_resource, context):
                        # Heuristic, do not compute sidebar view
                        # if there is no items
                        sidebar = sidebar_view.GET(sidebar_resource, context)

        namespace["sidebar_view"] = sidebar
        namespace["sidebar"] = sidebar or namespace["context_menus"]

        # Language
        ws_languages = site_root.get_property("website_languages")
        accept = context.accept_language
        namespace["lang"] = accept.select_language(ws_languages)

        # Nav
        # If there is no template specify we simply return the namespace
        nav = self.build_nav_namespace(context)
        namespace["nav"] = nav
        namespace["nav_length"] = len(nav["items"])
        nav_template = self.nav_data["template"]
        if nav_template is not None:
            nav_template = self.get_resource(nav_template)
            namespace["nav"] = stl(nav_template, {"items": nav["items"]})

        # Footer
        namespace["footer"] = None
        footer_template = self.footer_data["template"]
        if footer_template is not None:
            ns_footer = self.build_footer_namespace(context)
            footer = None
            if len(ns_footer["items"]):
                footer_template = self.get_resource(footer_template)
                footer = stl(footer_template, ns_footer)
            namespace["footer"] = footer

        # Hide context menus if no user authenticated
        if context.user is None:
            namespace["context_menus"] = []

        # Allow to hide the menu if there is only one item
        namespace["display_menu"] = namespace["nav_length"] > 1

        # Admin bar
        if here_ac.is_allowed_to_edit(context.user, here):
            namespace["admin_bar"] = AdminBarTemplate(context=context)
        else:
            namespace["admin_bar"] = None

        # Search Template
        namespace["search"] = SearchTemplate(context=context)

        return namespace