def getCK_finder_url(self, type=None):
     """
     return browser url for a type
     """
     
     base_url = '%s/@@plone_ckfinder?' % self.ckfinder_basehref
     if type == 'file':
         base_url += 'typeview=file&media=file'
     elif type == 'flash':
         pid = 'browse_flashs_portal_types'
         flash_types = self.cke_properties.getProperty(pid)
         base_url += 'typeview=file&media=flash'
         for ftype in flash_types:
             base_url += '&types:list=%s' % url_quote(ftype)
     elif type == 'image':
         pid = 'browse_images_portal_types'
         image_types = self.cke_properties.getProperty(pid)
         base_url += 'typeview=image&media=image'
         for itype in image_types:
             base_url += '&types:list=%s' % url_quote(itype)
     elif type == 'album':
         base_url += '&types:list=%s' % url_quote('VindulaPhotoAlbum')                            
             
             
     return "'%s'" % base_url
Example #2
0
 def get_query(self, rstr, defaultVal, val=None, valType=str):
     retval = ''
     if val is not None:
         retval = rstr % url_quote(valType(val))
     else:
         retval = rstr % url_quote(valType(defaultVal))
     return retval
Example #3
0
 def get_query(self, rstr, defaultVal, val=None, valType=str):
     retval = ''
     if val is not None:
         retval = rstr % url_quote(valType(val))
     else:
         retval = rstr % url_quote(valType(defaultVal))
     return retval
Example #4
0
def addDialogIfNeeded(url):
    '''If the action url is not a dialog, we add a generic print dialog.
  '''
    parts = url.split('/')
    absolute_url = '/'.join(parts[:-1])
    action = parts[-1]
    action_list = action.split('?')
    action_id = action_list[0]
    form = getattr(context, action_id, None)

    # try to get format parameter if exists
    parameter_kw = {}
    format = ''
    if len(action_list) > 1:
        parameter_list = action.split('?')[1]
        parameter_tuple_list = [
            tuple(tuple_parameter.split('='))
            for tuple_parameter in parameter_list.split('&')
        ]
        parameter_kw = dict(parameter_tuple_list)
    meta_type = getattr(form, 'meta_type', None)
    if meta_type in (
            'ERP5 Form Printout',
            'ERP5 OOo Template',
    ):
        # The target is a Form Printout or OOoTemplate so use dedicated form_dialog to enable
        # conversion and/or deferred reporting
        if meta_type == 'ERP5 Form Printout':
            base_content_type = getattr(
                form, form.template).getProperty('content_type')
        else:
            base_content_type = form.getProperty('content_type')
        if parameter_kw.has_key('format'):
            # if format is passed in action url: remove it
            format = parameter_kw.pop('format')
            action = '%s?%s' % (action_id, '&'.join([
                '='.join(tuple_parameter)
                for tuple_parameter in parameter_kw.items()
            ]))
        url = '%s/Base_viewOOoPrintDialog?dialog_action_url=%s&base_content_type=%s&field_your_format=%s' % (
            context.absolute_url(), url_quote('%s/%s' %
                                              (absolute_url, action)),
            url_quote(base_content_type), url_quote(format))
    elif not (hasattr(form, 'pt') and form.pt == 'form_dialog'):
        url = '%s/Base_viewIntermediatePrintDialog?dialog_action_url=%s' % (
            context.absolute_url(), url_quote('%s/%s' %
                                              (absolute_url, action)))
    return url
Example #5
0
    def scripts(self):
        registry = self.registry()
        registry_url = registry.absolute_url()
        skinname = url_quote(self.skinname())
        # get the uncooked resources
        scripts = registry.getResources()
        result = []

        for script in scripts:
            # only consider enabled JS resources
            if not script.getEnabled():
                continue
            # Only include JS where the regular expression matches
            script_id = script.getId()
            if not any(map(lambda rx: re.findall(rx, script_id), INCLUDE)):
                continue

            if script.isExternalResource():
                src = "%s" % (script.getId(), )
            else:
                src = "%s/%s/%s" % (registry_url, skinname, script.getId())
            data = {
                "src": src,
            }
            result.append(data)
        return result
Example #6
0
    def register_newsletter(self):
        """Attribute browser view for subscribing newsletter."""
        context = aq_inner(self.context)
        form = self.request.form
        nlpath = form.get('path', None)
        if nlpath is not None:
            nlcentral = context.restrictedTraverse(nlpath)
            if getattr(nlcentral, 'spam_prevention', False) and (
                form.get('form.widgets.message') != '' or form.get('form.widgets.title') != ''
            ):
                log.warn('HONEYPOT FILLED. SUBSCRIBE REQUEST REJECTED')
                return self.request.response.redirect(context.absolute_url())

            format = form.get('form.widgets.format')[0]
            email = form.get('form.widgets.email')
            portal_actions = getToolByName(context, 'portal_actions')
            try:
                actions = portal_actions.listFilteredActionsFor(object=nlcentral)
            except AttributeError:
                return self.request.response.redirect(context.absolute_url())
            url = [action['url'] for action in actions['object']
                   if action['id'] == 'subscribe'][0]
            query_url = '{0}?email={1}&format={2}'.format(url, url_quote(email), format)
            if nlcentral.spam_prevention():
                query_url = '{0}&title=&message='.format(query_url)
            self.request.response.redirect(query_url)
Example #7
0
    def getStyle(self):
        """Returns a stylesheet with all content styles"""

        self.request.response.setHeader('Content-Type', 'text/css')

        registry = getToolByName(aq_inner(self.context), 'portal_css')
        registry_url = registry.absolute_url()
        context = aq_inner(self.context)

        styles = registry.getEvaluatedResources(context)
        skinname = url_quote(aq_inner(self.context).getCurrentSkinName())
        result = []

        for style in styles:
            if style.getMedia() not in (
                    'print', 'projection') and style.getRel() == 'stylesheet':
                if style.isExternalResource():
                    src = style.getId()
                else:
                    src = "<!-- @import url(%s/%s/%s); -->" % (
                        registry_url, skinname, style.getId())
                result.append(src)

        # BBB 2010-07-24 Support Plone 3
        portal_migration = getToolByName(self.context, 'portal_migration')
        if hasattr(portal_migration, 'getInstanceVersionTuple'):
            major_version = portal_migration.getInstanceVersionTuple()[0]
            if major_version == 3:
                css = self.context.restrictedTraverse('tiny_mce_plone3.css')(
                    self.context)
                result.append(css)

        return "\n".join(result)
Example #8
0
    def _get_articles(self):
        """
        Get all articles for our tags view

        :returns: Dictionary of all articles that are shown on home view
        :rtype:   dict
        """
        articles_all = ([], [])

        # XXX: Temporary workaround for not getting articles twice.
        # Get the articles
        use_filters = self.request.form.get('use_filters') == 'selected'
        articles_all = get_articles_search(
            self.request.form,
            use_filters=use_filters
        )

        # Get the GET arguments
        self.getArgs = '?came_from=search'
        for name in self.request.form:
            if name == 'query':
                self.getArgs += ('&' + name + '=' +
                                 url_quote(self.request.form[name]))
            else:
                tmpArgs = self.request.form[name]
                if isinstance(tmpArgs, list):
                    tmpArgs = ','.join(tmpArgs)
                self.getArgs += '&' + name + '=' + tmpArgs

        self.articles = {
            'intersection': articles_all[0],
            'union': articles_all[1],
            'all': articles_all[0] + articles_all[1]
        }
        return self.articles
Example #9
0
    def styles(self):
        registry = self.registry()
        registry_url = self._getRegistryURL(registry)

        styles = registry.getEvaluatedResources(self.context)
        skinname = url_quote(self.skinname())
        result = []
        for style in styles:
            rendering = style.getRendering()
            if rendering == 'link':
                src = "%s/%s/%s" % (registry_url, skinname, style.getId())
                data = {'rendering': rendering,
                        'media': style.getMedia(),
                        'rel': style.getRel(),
                        'title': style.getTitle(),
                        'conditionalcomment' : style.getConditionalcomment(),
                        'src': src}
            elif rendering == 'import':
                src = "%s/%s/%s" % (registry_url, skinname, style.getId())
                data = {'rendering': rendering,
                        'media': style.getMedia(),
                        'conditionalcomment' : style.getConditionalcomment(),
                        'src': src}
            elif rendering == 'inline':
                content = registry.getInlineResource(style.getId(),
                                                     self.context)
                data = {'rendering': rendering,
                        'media': style.getMedia(),
                        'conditionalcomment' : style.getConditionalcomment(),
                        'content': content}
            else:
                raise ValueError, "Unkown rendering method '%s' for style '%s'" % (rendering, style.getId())
            result.append(data)
        return result
    def scripts(self):
        registry = self.registry()
        registry_url = registry.absolute_url()
        context = aq_inner(self.context)

        skinname = self.skinname()
        scripts = registry.getEvaluatedResources(context, theme=skinname)

        skinpath = url_quote(skinname)
        result = []
        for script in scripts:
            inline = bool(script.getInline())
            if inline:
                content = registry.getInlineResource(script.getId(), context)
                data = {'inline': inline,
                        'conditionalcomment': script.getConditionalcomment(),
                        'content': content}
            else:
                if script.isExternalResource():
                    src = "%s" % (script.getId(),)
                else:
                    src = "%s/%s/%s" % (registry_url, skinpath, script.getId())
                data = {'inline': inline,
                        'conditionalcomment': script.getConditionalcomment(),
                        'src': src}
            result.append(data)
        return result
Example #11
0
    def scripts(self):
        registry = self.registry()
        registry_url = registry.absolute_url()
        context = aq_inner(self.context)

        if self.request.get('HTTP_X_THEME_ENABLED'):
            skinname = 'bccvl.theme'
        else:
            skinname = url_quote(self.skinname())
        scripts = registry.getEvaluatedResources(context, skinname)
        result = []
        for script in scripts:
            inline = bool(script.getInline())
            if inline:
                content = registry.getInlineResource(script.getId(), context)
                data = {'inline': inline,
                        'conditionalcomment' : script.getConditionalcomment(),
                        'content': content,
                        'bundle': script.getBundle()
                }
            else:
                if script.isExternalResource():
                    src = "%s" % (script.getId(),)
                else:
                    src = "%s/%s/%s" % (registry_url, skinname, script.getId())
                data = {'inline': inline,
                        'conditionalcomment' : script.getConditionalcomment(),
                        'src': src,
                        'bundle': script.getBundle()
                }
            result.append(data)
        return result
Example #12
0
    def scripts(self):
        registry = self.registry()
        registry_url = registry.absolute_url()
        context = aq_inner(self.context)

        if self.request.get('HTTP_X_THEME_ENABLED'):
            skinname = 'bccvl.theme'
        else:
            skinname = url_quote(self.skinname())
        scripts = registry.getEvaluatedResources(context, skinname)
        result = []
        for script in scripts:
            inline = bool(script.getInline())
            if inline:
                content = registry.getInlineResource(script.getId(), context)
                data = {
                    'inline': inline,
                    'conditionalcomment': script.getConditionalcomment(),
                    'content': content,
                    'bundle': script.getBundle()
                }
            else:
                if script.isExternalResource():
                    src = "%s" % (script.getId(), )
                else:
                    src = "%s/%s/%s" % (registry_url, skinname, script.getId())
                data = {
                    'inline': inline,
                    'conditionalcomment': script.getConditionalcomment(),
                    'src': src,
                    'bundle': script.getBundle()
                }
            result.append(data)
        return result
Example #13
0
    def __init__(self, context, request):
        super(PluginView, self).__init__(context, request)
        pp = getToolByName(context, 'portal_properties')

        self.context = context
        self.request = request
        self.portal_state = getMultiAdapter((self.context, self.request),
                                            name=u'plone_portal_state')
        self.portal = self.portal_state.portal()
        self.site_url = self.portal_state.portal_url()
        self.portal_title = self.portal_state.portal_title()
        self.url = context.absolute_url()
        self.language = get_language(context)
        self.sheet = getattr(pp, 'sc_social_likes_properties', None)
        if self.sheet:
            self.typebutton = self.sheet.getProperty('typebutton', '')
            self.twittvia = self.sheet.getProperty('twittvia', '')
        self.urlnoscript = (
            u'http://twitter.com/home?status=' +
            url_quote(u'{0} - {1} via {2}'.format(
                safe_unicode(self.context.title),
                self.context.absolute_url(),
                self.twittvia)
            )
        )
Example #14
0
 def __init__(self, context, request):
     self.context = aq_inner(context)
     self.request = request
     self.language = get_language(context)
     data = url_quote('{0} - {1}'.format(safe_unicode(self.context.title),
                                         self.context.absolute_url()))
     self.whatsappurl = 'whatsapp://send?text={0}'.format(data)
Example #15
0
 def __init__(self, context, request):
     self.context = aq_inner(context)
     self.request = request
     self.language = get_language(context)
     data = url_quote(u'{0} - {1}'.format(
         safe_unicode(self.context.title), self.context.absolute_url()))
     self.whatsappurl = u'whatsapp://send?text={0}'.format(data)
Example #16
0
    def _get_articles(self):
        """
        Get all articles for our tags view.

        :returns: Dictionary of all articles that are shown on home view
        :rtype:   Dict
        """
        articles_all = ([], [])

        # XXX: Temporary workaround for not getting articles twice.
        if('form.buttons.filter' not in self.request.form and
           'form.buttons.text' not in self.request.form and
           'form.buttons.drag' not in self.request.form):
            # Get the articles
            articles_all = get_articles(self.request.form)

            # Get the GET arguments
            self.getArgs = ''
            for name in self.request.form:
                if name == 'query':
                    self.getArgs += ('&' + name + '=' +
                                     url_quote(self.request.form[name]))
                else:
                    self.getArgs += '&' + name + '=' + self.request.form[name]

            if self.getArgs:
                self.getArgs = '?' + self.getArgs[1:]

        self.articles = {
            'intersection': articles_all[0],
            'union': articles_all[1],
            'all': articles_all[0] + articles_all[1]
        }
        return self.articles
Example #17
0
    def __init__(self, context, request):
        """
        Initializes the article view

        :param    context: Current site context
        :type     context: Context object
        :param    request: Current HTTP request
        :type     request: Request object
        """

        self.context = context
        self.request = request

        self.getArgs = ''
        for name in self.request.form:
            if name not in ["annotation_tags", 'type', 'id']:
                if name == 'query':
                    self.getArgs += ('&' + name + '=' +
                                     url_quote(self.request.form[name]))
                else:
                    self.getArgs += '&' + name + '=' + self.request.form[name]

        if self.getArgs:
                self.getArgs = '?' + self.getArgs[1:]

        super(View, self).__init__(context, request)
Example #18
0
    def getTags(self):
        tagOccs = self.getTagOccurrences()
        # If count has been set sort by occurences and keep the "count" first

        if self.count:
            sortedOccs = sorted(tagOccs.items(),
                                key=itemgetter(1),
                                reverse=True)[:self.count]
            tagOccs = dict(sortedOccs)

        thresholds = self.getThresholds(tagOccs.values())
        tags = list(tagOccs.keys())
        tags.sort()
        res = []
        for tag in tags:
            d = {}
            size = self.getTagSize(tagOccs[tag], thresholds)
            if size == 0:
                continue
            d["text"] = tag
            d["class"] = "cloud" + str(size)
            href= self.portal_url + \
                "/?user="******"href"]=href
            d["count"] = translate(
                _(u'${count} items', mapping={'count': tagOccs[tag]}),
                context=self.request)
            res.append(d)
        return res
    def getCK_contentsCss(self):
        """
        return list of style sheets applied to ckeditor area
        the list is returned as a javascript string
        by default portal_css mixin + plone_ckeditor_area.css
        TODO : improve it with a control panel
        """
        context = aq_inner(self.context)
        portal = self.portal
        portal_url = self.portal_url
        portal_css = getToolByName(portal, 'portal_css')
        css_jsList = "["
        current_skin = context.getCurrentSkinName()
        skinname = url_quote(current_skin)
        css_res = portal_css.getEvaluatedResources(context)
        for css in css_res:
            media = css.getMedia()
            rel = css.getRel()
            if media not in ('print', 'projection') and rel == 'stylesheet':
                cssPloneId = css.getId()
                if ABSOLUTE_URL.match(cssPloneId):
                    css_jsList += "'%s', " % cssPloneId
                else:
                    cssPlone = '%s/portal_css/%s/%s' % (portal_url,
                                                        skinname,
                                                        cssPloneId)
                    css_jsList += "'%s', " % cssPlone

        baseres = '++resource++ckeditor_for_plone'
        css_jsList += "'%s/%s/ckeditor_plone_area.css']" % (portal_url,
                                                            baseres)

        return css_jsList
Example #20
0
    def scripts(self):
        registry = self.registry()
        registry_url = registry.absolute_url()
        context = aq_inner(self.context)

        scripts = registry.getEvaluatedResources(context)
        skinname = url_quote(self.skinname())
        result = []
        for script in scripts:
            inline = bool(script.getInline())
            if inline:
                content = registry.getInlineResource(script.getId(), context)
                data = {
                    'inline': inline,
                    'conditionalcomment': script.getConditionalcomment(),
                    'content': content
                }
            else:
                if script.isExternalResource():
                    src = "%s" % (script.getId(), )
                else:
                    src = "%s/%s/%s" % (registry_url, skinname, script.getId())
                data = {
                    'inline': inline,
                    'conditionalcomment': script.getConditionalcomment(),
                    'src': src
                }
            result.append(data)
        return result
Example #21
0
    def getStyle(self):
        """Returns a stylesheet with all content styles"""

        self.request.response.setHeader('Content-Type', 'text/css')

        registry = getToolByName(aq_inner(self.context), 'portal_css')
        registry_url = registry.absolute_url()
        context = aq_inner(self.context)

        styles = registry.getEvaluatedResources(context)
        skinname = url_quote(aq_inner(self.context).getCurrentSkinName())
        result = []

        for style in styles:
            if style.getMedia() not in ('print', 'projection') and style.getRel() == 'stylesheet':
                if style.isExternalResource():
                    src = style.getId()
                else:
                    src = "<!-- @import url(%s/%s/%s); -->" % (
                        registry_url, skinname, style.getId())
                result.append(src)

        # BBB 2010-07-24 Support Plone 3
        portal_migration = getToolByName(self.context, 'portal_migration')
        if hasattr(portal_migration, 'getInstanceVersionTuple'):
            major_version = portal_migration.getInstanceVersionTuple()[0]
            if major_version == 3:
                css = self.context.restrictedTraverse('tiny_mce_plone3.css')(self.context)
                result.append(css)

        return "\n".join(result)
Example #22
0
def AddParam2URL(url, params={}):
    """ return url and append params but be aware of existing params """
    p = '?'
    if p in url:
        p = '&'
    url = url + p
    for key, value in params.items():
        url = url + '%s=%s&' % (key, url_quote(value))
    return url[:-1]
Example #23
0
def AddParams2URL(url, params={}):
    """ return url and append params but be aware of existing params """
    p='?'
    if p in url:
        p = '&'
    url = url + p
    for key, value in params.items():
        url = url + '%s=%s&'%(key, url_quote(value))
    return url[:-1]
Example #24
0
def addDialogIfNeeded(url):
    """If the action url is not a dialog, we add a generic print dialog.
  """
    parts = url.split("/")
    absolute_url = "/".join(parts[:-1])
    action = parts[-1]
    action_list = action.split("?")
    action_id = action_list[0]
    form = getattr(context, action_id, None)

    # try to get format parameter if exists
    parameter_kw = {}
    format = ""
    if len(action_list) > 1:
        parameter_list = action.split("?")[1]
        parameter_tuple_list = [tuple(tuple_parameter.split("=")) for tuple_parameter in parameter_list.split("&")]
        parameter_kw = dict(parameter_tuple_list)
    meta_type = getattr(form, "meta_type", None)
    if meta_type in ("ERP5 Form Printout", "ERP5 OOo Template"):
        # The target is a Form Printout or OOoTemplate so use dedicated form_dialog to enable
        # conversion and/or deferred reporting
        if meta_type == "ERP5 Form Printout":
            base_content_type = getattr(form, form.template).getProperty("content_type")
        else:
            base_content_type = form.getProperty("content_type")
        if parameter_kw.has_key("format"):
            # if format is passed in action url: remove it
            format = parameter_kw.pop("format")
            action = "%s?%s" % (
                action_id,
                "&".join(["=".join(tuple_parameter) for tuple_parameter in parameter_kw.items()]),
            )
        url = "%s/Base_viewOOoPrintDialog?dialog_action_url=%s&base_content_type=%s&field_your_format=%s" % (
            context.absolute_url(),
            url_quote("%s/%s" % (absolute_url, action)),
            url_quote(base_content_type),
            url_quote(format),
        )
    elif not (hasattr(form, "pt") and form.pt == "form_dialog"):
        url = "%s/Base_viewIntermediatePrintDialog?dialog_action_url=%s" % (
            context.absolute_url(),
            url_quote("%s/%s" % (absolute_url, action)),
        )
    return url
Example #25
0
    def render(self):
        registry = self.context.portal_css
        registry_url = registry.absolute_url()
        context = aq_inner(self.context)
        portal = api.portal.get()

        styles = registry.getEvaluatedResources(context)
        skinname = url_quote(self.skinname())
        urls = []
        files = []
        for style in styles:
            rendering = style.getRendering()
            if style.isExternalResource():
                src = "%s" % style.getId()
            else:
                src = "%s/%s/%s" % (registry_url, skinname, style.getId())

            try:
                file_path = portal.restrictedTraverse(
                    re.sub(r'(http://[^\/]+)(.*)', r'\2', src)).context.path
            except:
                file_path = 'No path'

            if rendering == 'link':
                data = {
                    'rendering': rendering,
                    'media': style.getMedia(),
                    'rel': style.getRel(),
                    'title': style.getTitle(),
                    'conditionalcomment': style.getConditionalcomment(),
                    'src': src,
                    'file': file_path
                }
            elif rendering == 'import':
                data = {
                    'rendering': rendering,
                    'media': style.getMedia(),
                    'conditionalcomment': style.getConditionalcomment(),
                    'src': src,
                    'file': file_path
                }
            elif rendering == 'inline':
                content = registry.getInlineResource(style.getId(), context)
                data = {
                    'rendering': rendering,
                    'media': style.getMedia(),
                    'conditionalcomment': style.getConditionalcomment(),
                    'content': content
                }
            else:
                raise ValueError(
                    "Unkown rendering method '%s' for style '%s'" %
                    (rendering, style.getId()))
            urls.append(data['src'])
            files.append(data['file'])
        return urls + files
Example #26
0
 def _setup(self):
     self.portal_state = getMultiAdapter(
         (self.context, self.request), name=u'plone_portal_state')
     self.portal = self.portal_state.portal()
     self.site_url = self.portal_state.portal_url()
     self.portal_title = self.portal_state.portal_title()
     self.url = self.context.absolute_url()
     self.language = get_language(self.context)
     data = url_quote(self.context.absolute_url())
     self.telegramurl = u'https://telegram.me/share/url?url={0}'.format(data)
 def manage_unregisterLayout(self, REQUEST, manage_tabs_message=None, type=None, layout_id=None):
     """
     unregister layouts for type
     """
     if type is not None:
         layout = self.getLayoutById(layout_id)
         if layout:
             self.unregisterLayoutForType(layout, type)
     # return self.manage_layouts(REQUEST, type=type)
     return self.REQUEST.RESPONSE.redirect("manage_layouts?type=%s" % url_quote(type))
    def getTags(self):
        tagOccs = self.getTagOccurrences()
        # If count has been set sort by occurences and keep the "count" first

        if self.count:
            sortedOccs = sorted(tagOccs.items(),
                                key=itemgetter(1),
                                reverse=True)[:self.count]
            tagOccs = dict(sortedOccs)

        thresholds = self.getThresholds(tagOccs.values())
        tags = list(tagOccs.keys())
        tags.sort()
        res = []
        for tag in tags:
            d = {}
            size = self.getTagSize(tagOccs[tag], thresholds)
            if size == 0:
                continue
            d["text"] = tag
            d["class"] = "cloud" + str(size)
            href= self.portal_url + \
                "/@@search?Subject%3Alist="+url_quote(tag)
            #Add type restrictions to search link
            href = href + "".join([
                "&portal_type%3Alist=" + url_quote(ptype)
                for ptype in self.restrictTypes
            ])
            #Add workflow restrictions to search link
            href = href + "".join([
                "&review_state%3Alist=" + url_quote(wstate)
                for wstate in self.wfStates
            ])
            #Add path to search link
            if self.root:
                href = href + "&path=%s" % getNavigationRoot(
                    self.context, relativeRoot=self.root)
            d["href"] = href
            d["count"] = translate(_(u'${count} items',
                                     mapping={'count': tagOccs[tag]}),
                                   context=self.request)
            res.append(d)
        return res
 def manage_unregisterViewlet(self, REQUEST, manage_tabs_message=None, type=None, viewlet_id=None):
     """
     unregister viewlets for type
     """
     if type is not None:
         viewlet = self.getViewletById(viewlet_id)
         if viewlet:
             self.unregisterViewletForType(viewlet, type)
     # return self.manage_viewlets(REQUEST, type=type)
     return self.REQUEST.RESPONSE.redirect("manage_viewlets?type=%s" % url_quote(type))
    def getTags(self):
        tagOccs = self.getTagOccurrences()
        # If count has been set sort by occurences and keep the "count" first

        if self.count:
            sortedOccs = sorted(tagOccs.items(),
                                key=itemgetter(1),
                                reverse=True)[:self.count]
            tagOccs = dict(sortedOccs)

        thresholds = self.getThresholds(tagOccs.values())
        tags = tagOccs.keys()
        tags.sort()
        res = []
        for tag in tags:
            item = {}
            size = self.getTagSize(tagOccs[tag], thresholds)
            if size == 0:
                continue
            item["text"] = tag
            item["class"] = "cloud" + str(size)
            href = self.portal_url + "/@@search?Subject%3Alist=" + url_quote(tag)
            #Add type restrictions to search link
            href = href + "".join([
                "&portal_type%3Alist=" + url_quote(ptype)
                for ptype in self.restrictTypes
            ])
            #Add workflow restrictions to search link
            href = href + "".join([
                "&review_state%3Alist=" + url_quote(wstate)
                for wstate in self.wfStates
            ])
            #Add path to search link
            if self.root:
                nav_root = getNavigationRoot(self.context,
                                             relativeRoot=self.root)
                href = href + "&path=%s" % nav_root
            item["href"] = href
            msg = _(u'${count} items', mapping={'count': tagOccs[tag]})
            item["count"] = translate(msg, context=self.request)
            res.append(item)
        return res
Example #31
0
 def getCK_finder_url(self, type=None):
     """
     return browser url for a type
     """
     base_url = "%s/@@plone_ckfinder?" % self.ckfinder_basehref
     if type == "file":
         base_url += "typeview=file&media=file"
     elif type == "flash":
         pid = "browse_flashs_portal_types"
         flash_types = self.cke_properties.getProperty(pid)
         base_url += "typeview=file&media=flash"
         for ftype in flash_types:
             base_url += "&types:list=%s" % url_quote(ftype)
     elif type == "image":
         pid = "browse_images_portal_types"
         image_types = self.cke_properties.getProperty(pid)
         base_url += "typeview=image&media=image"
         for itype in image_types:
             base_url += "&types:list=%s" % url_quote(itype)
     return "'%s'" % base_url
 def getCK_finder_url(self, type=None):
     """
     return browser url for a type
     """
     base_url = '%s/@@plone_ckfinder?' % self.ckfinder_basehref
     if type == 'file':
         base_url += 'typeview=file&media=file'
     elif type == 'flash':
         pid = 'browse_flashs_portal_types'
         flash_types = self.cke_properties.getProperty(pid)
         base_url += 'typeview=file&media=flash'
         for ftype in flash_types:
             base_url += '&types:list=%s' % url_quote(ftype)
     elif type == 'image':
         pid = 'browse_images_portal_types'
         image_types = self.cke_properties.getProperty(pid)
         base_url += 'typeview=image&media=image'
         for itype in image_types:
             base_url += '&types:list=%s' % url_quote(itype)
     return "'%s'" % base_url
Example #33
0
 def _setup(self):
     self.portal_state = getMultiAdapter((self.context, self.request),
                                         name=u'plone_portal_state')
     self.portal = self.portal_state.portal()
     self.site_url = self.portal_state.portal_url()
     self.portal_title = self.portal_state.portal_title()
     self.url = self.context.absolute_url()
     self.language = get_language(self.context)
     data = url_quote(self.context.absolute_url())
     self.telegramurl = u'https://telegram.me/share/url?url={0}'.format(
         data)
Example #34
0
 def get_extra_feeds(self):
     """Return extra feeds such as Blog and OSHA in the media"""
     portal_path = self._getPortalPath()
     lang = self._getPreferedLanguage()
     media_title = translate(
         msgid=_(u'eu_osha_in_the_media',
                 default=u'EU-OSHA in the media'),
         target_language=lang, context=self.context)
     media_url_title = unicode(
         url_quote(media_title.encode('utf-8')), 'utf-8')
     blog_title = translate(
         msgid=_(u'eu_osha_blog', default=u'The EU-OSHA Blog'),
         target_language=lang, context=self.context)
     blog_url_title = unicode(
         url_quote(blog_title.encode('utf-8')), 'utf-8')
     jobs_title = translate(
         msgid=_(u'eu_osha_current_jobs',
                 default=u'EU-OSHA Current job vacancies'),
         target_language=lang, context=self.context)
     jobs_url_title = unicode(
         url_quote(jobs_title.encode('utf-8')), 'utf-8')
     feeds = [
         dict(
             title=media_title,
             icon="newsitem_icon.gif",
             url=(portal_path + '/en/press/sinRSS?synmap=MemoNews&RSSTitle='
                  + media_url_title)),
         dict(
             title=blog_title,
             icon="newsitem_icon.gif",
             url=(portal_path + '/en/blog/front-page/RSS?RSSTitle=' +
                  blog_url_title)),
         dict(
             title=jobs_title,
             icon="newsitem_icon.gif",
             url=(portal_path +
                  '/en/about/jobs/@@rss-current-jobs?RSSTitle=' +
                  jobs_url_title),
         )
     ]
     return feeds
Example #35
0
 def get_extra_feeds(self):
     """Return extra feeds such as Blog and OSHA in the media"""
     portal_path = self._getPortalPath()
     lang = self._getPreferedLanguage()
     media_title = translate(msgid=_(u'eu_osha_in_the_media',
                                     default=u'EU-OSHA in the media'),
                             target_language=lang,
                             context=self.context)
     media_url_title = unicode(url_quote(media_title.encode('utf-8')),
                               'utf-8')
     blog_title = translate(msgid=_(u'eu_osha_blog',
                                    default=u'The EU-OSHA Blog'),
                            target_language=lang,
                            context=self.context)
     blog_url_title = unicode(url_quote(blog_title.encode('utf-8')),
                              'utf-8')
     jobs_title = translate(msgid=_(
         u'eu_osha_current_jobs', default=u'EU-OSHA Current job vacancies'),
                            target_language=lang,
                            context=self.context)
     jobs_url_title = unicode(url_quote(jobs_title.encode('utf-8')),
                              'utf-8')
     feeds = [
         dict(title=media_title,
              icon="newsitem_icon.gif",
              url=(portal_path +
                   '/en/press/sinRSS?synmap=MemoNews&RSSTitle=' +
                   media_url_title)),
         dict(title=blog_title,
              icon="newsitem_icon.gif",
              url=(portal_path + '/en/blog/front-page/RSS?RSSTitle=' +
                   blog_url_title)),
         dict(
             title=jobs_title,
             icon="newsitem_icon.gif",
             url=(portal_path +
                  '/en/about/jobs/@@rss-current-jobs?RSSTitle=' +
                  jobs_url_title),
         )
     ]
     return feeds
Example #36
0
File: kss.py Project: dtgit/dtedu
    def kineticstylesheets(self):
        registry = self.registry()
        registry_url = registry.absolute_url()

        kineticstylesheets = registry.getEvaluatedResources(self.context)
        skinname = url_quote(self.skinname())
        result = []
        for kss in kineticstylesheets:
            src = "%s/%s/%s" % (registry_url, skinname, kss.getId())
            data = {'src': src}
            result.append(data)
        return result
Example #37
0
def addDialogIfNeeded(url):
  '''If the action url is not a dialog, we add a generic print dialog.
  '''
  parts = url.split('/')
  absolute_url = '/'.join(parts[:-1])
  action = parts[-1]
  action_id = action.split('?')[0]
  form = getattr(context, action_id, None)
  #if not (hasattr(form, 'pt') and form.pt == 'form_dialog'):
  if form is not None:
    url = '%s/Base_viewIntermediatePrintDialog?dialog_action_url=%s' % (
                 context.absolute_url(), url_quote('%s/%s' % (absolute_url, action)))
  return url
 def manage_defaultViewlet(self, REQUEST, manage_tabs_message=None, type=None, default=None):
     """
     set default viewlet for type
     """
     if type is not None:
         if default == "nodefault":
             self.clearDefaultViewletForType(type)
         else:
             viewlet = self.getViewletById(default)
             if viewlet:
                 self.setDefaultViewletForType(viewlet, type)
     # return self.manage_viewlets(REQUEST, type=type)
     return self.REQUEST.RESPONSE.redirect("manage_viewlets?type=%s" % url_quote(type))
Example #39
0
 def __call__(self):
     tracker = aq_inner(self.context)
     search_text = self.request.form.get('searchText', '')
     issue_id = search_text
     if issue_id.startswith('#'):
         issue_id = issue_id[1:]
     base_url = tracker.absolute_url()
     if issue_id in tracker.keys():
         url = '%s/%s' % (base_url, issue_id)
     else:
         url = '%s/poi_issue_search?SearchableText=%s' % (
             base_url, url_quote(search_text))
     self.request.RESPONSE.redirect(url)
Example #40
0
 def getUrlFinder(self,field):
     url_finder = 'refbrowser_finder?fieldName=%s&mult=%s&' %(field.getName(),field.multiValued)
     url_finder += 'typeview=%s&media=%s&allowimagesizeselection:boolean=False&' %(self.typeview,self.typeview)
     if self.allowupload:
         url_finder += 'allowupload:boolean=%s&' %self.allowupload
     if self.allowaddfolder:
         url_finder += 'allowaddfolder:boolean=%s&' %self.allowaddfolder
         
     if field.allowed_types:
         if type(field.allowed_types) == tuple:   
             for itype in tuple(field.allowed_types):
                 url_finder += 'types:list=%s&' % url_quote(itype)
         else:
             url_finder += 'types:list=%s&' % url_quote(field.allowed_types)
     if self.review_state:
         if isinstance(self.review_state, tuple):
             for itype in tuple(self.review_state):
                 url_finder += 'review_state:list=%s&' % url_quote(itype)
         else:
             url_finder += 'review_state=%s&' %url_quote(self.review_state)
     
     return url_finder
Example #41
0
 def __call__(self):
     tracker = aq_inner(self.context)
     search_text = self.request.form.get('searchText', '')
     issue_id = search_text
     if issue_id.startswith('#'):
         issue_id = issue_id[1:]
     base_url = tracker.absolute_url()
     if issue_id in tracker.keys():
         url = '%s/%s' % (base_url, issue_id)
     else:
         url = '%s/poi_issue_search?SearchableText=%s' % (
             base_url, url_quote(search_text))
     self.request.RESPONSE.redirect(url)
 def manage_defaultLayout(self, REQUEST, manage_tabs_message=None, type=None, default=None):
     """
     set default layout for type
     """
     if type is not None:
         if default == "nodefault":
             self.clearDefaultLayoutForType(type)
         else:
             layout = self.getLayoutById(default)
             if layout:
                 self.setDefaultLayoutForType(layout, type)
     # return self.manage_layouts(REQUEST, type=type)
     return self.REQUEST.RESPONSE.redirect("manage_layouts?type=%s" % url_quote(type))
Example #43
0
    def ignoreIssueTracker(self, path, REQUEST=None):
        """ add this to the cookie """
        # if path == '/Image Test' convert it to '/Image Test'
        path = url_quote(path)
        paths = self.getSkippablePaths()
        if path in paths:
            paths.remove(path)

        paths.insert(0, path)
        self._saveSkippablePaths(paths)

        if REQUEST is not None:
            REQUEST.RESPONSE.redirect(self.getRootURL())
Example #44
0
def addDialogIfNeeded(url):
    '''If the action url is not a dialog, we add a generic print dialog.
  '''
    parts = url.split('/')
    absolute_url = '/'.join(parts[:-1])
    action = parts[-1]
    action_id = action.split('?')[0]
    form = getattr(context, action_id, None)
    #if not (hasattr(form, 'pt') and form.pt == 'form_dialog'):
    if form is not None:
        url = '%s/Base_viewIntermediatePrintDialog?dialog_action_url=%s' % (
            context.absolute_url(), url_quote('%s/%s' %
                                              (absolute_url, action)))
    return url
Example #45
0
    def styles(self):
        registry = self.registry()
        registry_url = registry.absolute_url()
        context = aq_inner(self.context)

        if self.request.get('HTTP_X_THEME_ENABLED'):
            skinname = 'bccvl.theme'
        else:
            skinname = url_quote(self.skinname())
        styles = registry.getEvaluatedResources(context, skinname)
        result = []
        for style in styles:
            rendering = style.getRendering()
            if style.isExternalResource():
                src = "%s" % style.getId()
            else:
                src = "%s/%s/%s" % (registry_url, skinname, style.getId())
            if rendering == 'link':
                data = {
                    'rendering': rendering,
                    'media': style.getMedia(),
                    'rel': style.getRel(),
                    'title': style.getTitle(),
                    'conditionalcomment': style.getConditionalcomment(),
                    'src': src,
                    'bundle': style.getBundle()
                }
            elif rendering == 'import':
                data = {
                    'rendering': rendering,
                    'media': style.getMedia(),
                    'conditionalcomment': style.getConditionalcomment(),
                    'src': src,
                    'bundle': style.getBundle()
                }
            elif rendering == 'inline':
                content = registry.getInlineResource(style.getId(), context)
                data = {
                    'rendering': rendering,
                    'media': style.getMedia(),
                    'conditionalcomment': style.getConditionalcomment(),
                    'content': content,
                    'bundle': style.getBundle()
                }
            else:
                raise ValueError(
                    "Unkown rendering method '%s' for style '%s'" %
                    (rendering, style.getId()))
            result.append(data)
        return result
Example #46
0
 def manage_unregisterViewlet(self,
                              REQUEST,
                              manage_tabs_message=None,
                              type=None,
                              viewlet_id=None):
     '''
     unregister viewlets for type
     '''
     if type is not None:
         viewlet = self.getViewletById(viewlet_id)
         if viewlet:
             self.unregisterViewletForType(viewlet, type)
     #return self.manage_viewlets(REQUEST, type=type)
     return self.REQUEST.RESPONSE.redirect('manage_viewlets?type=%s' %
                                           url_quote(type))
Example #47
0
 def manage_unregisterLayout(self,
                             REQUEST,
                             manage_tabs_message=None,
                             type=None,
                             layout_id=None):
     '''
     unregister layouts for type
     '''
     if type is not None:
         layout = self.getLayoutById(layout_id)
         if layout:
             self.unregisterLayoutForType(layout, type)
     #return self.manage_layouts(REQUEST, type=type)
     return self.REQUEST.RESPONSE.redirect('manage_layouts?type=%s' %
                                           url_quote(type))
Example #48
0
 def subject_feeds(self):
     url_pattern = self._getPortalPath() + u"/search_rss?Subject=%(id)s&RSSTitle=%(title)s&Language=%(lang)s&review_state=published&sort_on=effective"
     retval = []
     lang = self._getPreferedLanguage()
     for id, title in self._getTranslatedCategories():
         title = 'EU-OSHA ' + title
         url_title = unicode(url_quote(title.encode('utf-8')), 'utf-8')
         retval.append(dict(
             id=id,
             title=title,
             icon='topic_icon.gif',
             url=(url_pattern % (dict(
                 title=url_title, id=id, lang=lang))).encode('utf-8'),
             ))
     return retval
Example #49
0
    def buildGetArgs(self, home=False, search=False):
        """
        Build GET arguments from the sidebar selections.

        :returns: GET arguments to append to an URL
        :rtype:   String
        """
        other_names = ['sort_on', 'view_type']

        if home:
            return ('?view_type=' +
                    self.request.form.get("form.widgets.view_type")[0])

        # Append tags, depending on if we're searching or not
        st = ""
        name = 'form.widgets.all_tags'
        if not search:
            if name in self.request.form:
                st += '/' + ','.join(self.request.form[name])
        else:
            if name in self.request.form:
                st += '&tags=' + ','.join(self.request.form[name])
            st += '&query="{0}"'.format(
                url_quote(self.request.form.get('form.widgets.query'))
            )
            other_names.append('use_filters')

        # Append all filters except none
        name = 'form.widgets.content_filters'
        st += '&filters='
        if name in self.request.form:
            st += ','.join((i for i in self.request.form[name]
                            if i != 'all'))
        # If we have no filters, make sure we save that too
        else:
            st += "None"

        # Append sort_on and view_type
        for subname in other_names:
            name = 'form.widgets.' + subname
            if name in self.request.form:
                st += '&' + subname + '=' + ','.join(self.request.form[name])

        # Change the first GET parameter from &name=value to ?name=value
        first_letter = st.find('&')
        if first_letter != -1:
            st = st[:first_letter] + '?' + st[first_letter + 1:]
        return st
Example #50
0
 def __init__(self, context, request):
     self.context = context
     self.request = request
     # FIXME: the following could rise unexpected exceptions
     #        move it to a new setup() method
     #        see: http://docs.plone.org/develop/plone/views/browserviews.html#creating-a-view
     self.portal_state = getMultiAdapter((self.context, self.request),
                                         name=u'plone_portal_state')
     self.portal = self.portal_state.portal()
     self.site_url = self.portal_state.portal_url()
     self.portal_title = self.portal_state.portal_title()
     self.url = context.absolute_url()
     self.language = get_language(context)
     data = url_quote(u'{0} - {1}'.format(safe_unicode(self.context.title),
                                          self.context.absolute_url()))
     self.whatsappurl = u'whatsapp://send?text={0}'.format(data)
Example #51
0
 def __init__(self, context, request):
     self.context = context
     self.request = request
     # FIXME: the following could rise unexpected exceptions
     #        move it to a new setup() method
     #        see: http://docs.plone.org/develop/plone/views/browserviews.html#creating-a-view
     self.portal_state = getMultiAdapter((self.context, self.request),
                                         name=u'plone_portal_state')
     self.portal = self.portal_state.portal()
     self.site_url = self.portal_state.portal_url()
     self.portal_title = self.portal_state.portal_title()
     self.url = context.absolute_url()
     self.language = get_language(context)
     self.urlnoscript = (u'http://twitter.com/home?status=' + url_quote(
         u'{0} - {1} via {2}'.format(safe_unicode(
             self.context.title), self.context.absolute_url(), self.via)))
Example #52
0
 def subject_feeds(self):
     url_pattern = self._getPortalPath(
     ) + u"/search_rss?Subject=%(id)s&RSSTitle=%(title)s&Language=%(lang)s&review_state=published&sort_on=effective"
     retval = []
     lang = self._getPreferedLanguage()
     for id, title in self._getTranslatedCategories():
         title = 'EU-OSHA ' + title
         url_title = unicode(url_quote(title.encode('utf-8')), 'utf-8')
         retval.append(
             dict(
                 id=id,
                 title=title,
                 icon='topic_icon.gif',
                 url=(url_pattern % (dict(title=url_title, id=id,
                                          lang=lang))).encode('utf-8'),
             ))
     return retval
Example #53
0
    def __init__(self, context, request):
        super(PluginView, self).__init__(context, request)
        pp = getToolByName(context, 'portal_properties')

        self.context = context
        self.request = request
        self.portal_state = getMultiAdapter((self.context, self.request),
                                            name=u'plone_portal_state')
        self.portal = self.portal_state.portal()
        self.site_url = self.portal_state.portal_url()
        self.portal_title = self.portal_state.portal_title()
        self.url = context.absolute_url()
        self.language = get_language(context)
        self.sheet = getattr(pp, 'sc_social_likes_properties', None)
        self.whatsappurl = (
            u'whatsapp://send?text=' +
            url_quote(u'{0} - {1}'.format(safe_unicode(self.context.title),
                                          self.context.absolute_url())))
Example #54
0
    def type_feeds(self):
        """ return all feeds by typical types and offer subfeeds by keyword
        """

        retval = []
        lang = self._getPreferedLanguage()
        portal_path = self._getPortalPath()

        for type in self._getTypesForFeeds():
            url = portal_path + type['base_url'] % dict(
                lang=lang, sorter="effective", title=url_quote(type['title']))

            retval.append(
                dict(id=type['doc_type'],
                     title=type['title'],
                     icon=type['icon'],
                     url=url))
        return retval
Example #55
0
 def manage_defaultLayout(self,
                          REQUEST,
                          manage_tabs_message=None,
                          type=None,
                          default=None):
     '''
     set default layout for type
     '''
     if type is not None:
         if default == 'nodefault':
             self.clearDefaultLayoutForType(type)
         else:
             layout = self.getLayoutById(default)
             if layout:
                 self.setDefaultLayoutForType(layout, type)
     #return self.manage_layouts(REQUEST, type=type)
     return self.REQUEST.RESPONSE.redirect('manage_layouts?type=%s' %
                                           url_quote(type))
Example #56
0
 def manage_defaultViewlet(self,
                           REQUEST,
                           manage_tabs_message=None,
                           type=None,
                           default=None):
     '''
     set default viewlet for type
     '''
     if type is not None:
         if default == 'nodefault':
             self.clearDefaultViewletForType(type)
         else:
             viewlet = self.getViewletById(default)
             if viewlet:
                 self.setDefaultViewletForType(viewlet, type)
     #return self.manage_viewlets(REQUEST, type=type)
     return self.REQUEST.RESPONSE.redirect('manage_viewlets?type=%s' %
                                           url_quote(type))
Example #57
0
    def test_allMetaTypes(self):
        """
        Test that everything returned by allMetaTypes can be
        traversed to.
        """
        tool = self.ttool
        meta_types = {}
        # Seems we get NullResource if the method couldn't be traverse to
        # so we check for that. If we've got it, something is b0rked.
        for factype in tool.all_meta_types():
            meta_types[factype['name']] = 1
            # The url_quote below is necessary 'cos of the one in
            # main.dtml. Could be removed once that is gone.
            act = tool.unrestrictedTraverse(url_quote(factype['action']))
            self.failIf(type(aq_base(act)) is NullResource)

        # Check the ones we're expecting are there
        self.failUnless(meta_types.has_key('Scriptable Type Information'))
        self.failUnless(meta_types.has_key('Factory-based Type Information'))