Skip to content

Commit

Permalink
Merge branch 'master' into plip10359-security-controlpanel
Browse files Browse the repository at this point in the history
Conflicts:
	CHANGES.rst
  • Loading branch information
Timo Stollenwerk committed Feb 27, 2015
2 parents 24d7cb6 + 5fbeaf7 commit 8d8c3cc
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 32 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ Changelog
properties (see https://github.com/plone/Products.CMFPlone/issues/216).
[jcerjak]

- use livesearch pattern
[vangheem]

- use configuration registry pattern options
[vangheem]

- Added support for site logos stored in the portal registry via the site
control panel for the logo viewlet with a fallback to the ``OFS.Image``
based ``logo.png`` file. Removed support of long-gone
Expand Down
30 changes: 19 additions & 11 deletions plone/app/layout/globals/patterns_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

from zope.interface import implements
from zope.component import getAdapters
from zope.component.hooks import getSite
from zope.publisher.browser import BrowserView
from .interfaces import IPatternsSettingsRenderer
from Products.CMFPlone.interfaces import IPatternsSettings

import json
from plone.registry.interfaces import IRegistry
from zope.component import getUtility
from zope.component import getMultiAdapter


class PatternsSettings(BrowserView):
Expand All @@ -17,20 +17,28 @@ class PatternsSettings(BrowserView):
implements(IPatternsSettingsRenderer)

def __call__(self):
modal_options = {
'actionOptions': {
'displayInModal': False,
}
}
base_url = getSite().absolute_url()
portal_state = getMultiAdapter(
(self.context, self.request), name=u'plone_portal_state')
# do not use getSite because it's possible it could be different
# than the actual portal url
base_url = portal_state.portal_url()
result = {
'data-pat-modal': json.dumps(modal_options),
'data-base-url': self.context.absolute_url(),
'data-portal-url': base_url,
'data-i18ncatalogurl': base_url + '/plonejsi18n'
}

# first, check for any adapters that need pattern data defined
adapters = getAdapters((self.context, self.request, None), IPatternsSettings)
[result.update(x[1]()) for x in adapters]
return result

# Resources Registered UI patterns can override adapters
registry = getUtility(IRegistry)
try:
pattern_options = registry['plone.patternoptions']
except (AttributeError, KeyError):
pattern_options = {}
for key, value in pattern_options.items():
result['data-pat-' + key] = value

return result
33 changes: 33 additions & 0 deletions plone/app/layout/globals/tests/test_pattern_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from plone.app.layout.globals.tests.base import GlobalsTestCase
from plone.app.layout.globals.patterns_settings import PatternsSettings
from plone.registry.interfaces import IRegistry
from zope.component import getUtility


class TestPatternSettings(GlobalsTestCase):
"""Ensure that the basic redirector setup is successful.
"""

def testShouldReturnCorrectType(self):
settings = PatternsSettings(self.folder, self.app.REQUEST)
result = settings()
self.assertEquals(type(result), dict)
for key, value in result.items():
self.assertTrue(isinstance(key, basestring))
self.assertTrue(isinstance(value, basestring))

def testUrls(self):
settings = PatternsSettings(self.folder, self.app.REQUEST)
result = settings()
self.assertEquals(result['data-base-url'], self.folder.absolute_url())
self.assertEquals(result['data-portal-url'], self.portal.absolute_url())

def testPatternOptions(self):
registry = getUtility(IRegistry)
registry['plone.patternoptions'] = {
'foo': u'{"foo": "bar"}'
}

settings = PatternsSettings(self.folder, self.app.REQUEST)
result = settings()
self.assertEquals(result['data-pat-foo'], u'{"foo": "bar"}')
13 changes: 7 additions & 6 deletions plone/app/layout/links/viewlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,13 @@ def update(self):
settings = registry.forInterface(ISiteSyndicationSettings)
except KeyError:
return
for uid in settings.site_rss_items:
obj = uuidToObject(uid)
if obj is not None:
self.rsslinks.extend(self.getRssLinks(obj))
self.rsslinks.extend(self.getRssLinks(
self.portal_state.portal()))
if settings.site_rss_items:
for uid in settings.site_rss_items:
obj = uuidToObject(uid)
if obj is not None:
self.rsslinks.extend(self.getRssLinks(obj))
self.rsslinks.extend(self.getRssLinks(
self.portal_state.portal()))
else:
if util.context_enabled():
self.rsslinks.extend(self.getRssLinks(self.context))
Expand Down
11 changes: 4 additions & 7 deletions plone/app/layout/viewlets/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.interfaces import ISiteSchema
from Products.CMFPlone.interfaces import ISearchSchema
from Products.CMFPlone.utils import safe_unicode
from Products.CMFPlone.interfaces import IPloneSiteRoot
from Products.Five.browser import BrowserView
Expand Down Expand Up @@ -175,13 +176,9 @@ def update(self):
context_state = getMultiAdapter((self.context, self.request),
name=u'plone_context_state')

props = getToolByName(self.context, 'portal_properties')
livesearch = props.site_properties.getProperty(
'enable_livesearch', False)
if livesearch:
self.search_input_id = "searchGadget"
else:
self.search_input_id = "nolivesearchGadget" # don't use "" here!
registry = getUtility(IRegistry)
search_settings = registry.forInterface(ISearchSchema, prefix='plone')
self.livesearch = search_settings.enable_livesearch

folder = context_state.folder()
self.folder_path = '/'.join(folder.getPhysicalPath())
Expand Down
14 changes: 6 additions & 8 deletions plone/app/layout/viewlets/searchbox.pt
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<div id="portal-searchbox"
i18n:domain="plone"
tal:define="navigation_root_url view/navigation_root_url;
search_input_id view/search_input_id;">
tal:define="navigation_root_url view/navigation_root_url;">

<form id="searchGadget_form"
action="@@search"
role="search"
tal:attributes="action string:${navigation_root_url}/@@search;
id string:${search_input_id}_form;">
data-pat-livesearch string:ajaxUrl:${navigation_root_url}/@@ajax-search;
class python: view.livesearch and 'pat-livesearch' or ''">

<div class="LSBox">
<label class="hiddenStructure"
tal:attributes="for search_input_id"
for="searchGadget"
i18n:translate="text_search">Search Site</label>

<input name="SearchableText"
type="text"
size="18"
value=""
id="searchGadget"
title="Search Site"
placeholder="Search Site"
accesskey="4"
i18n:attributes="title title_search_site;
placeholder title_search_site"
tal:attributes="value request/form/SearchableText|nothing;
id search_input_id"
tal:attributes="value request/form/SearchableText|nothing;"
class="searchField" />

<input class="searchButton"
Expand All @@ -46,8 +46,6 @@
only in current section
</label>
</div>

<div class="LSResult" id="LSResult"><div class="LSShadow" id="LSShadow"></div></div>
</div>
</form>

Expand Down

0 comments on commit 8d8c3cc

Please sign in to comment.