from Products.Silva.mangle import String

request = context.REQUEST
node = request.node
editor = context.service_editorsupport

model = node.get_content()

if request['what'] != 'heading':
    context.element_switch()
    return

data = request['data']
type = request['element_type']

supp = editor.getMixedContentSupport(model, node)
supp.parse(data)

# special case of element switching:
if getattr(request, 'element_switched', None):
    title = getattr(request, 'list_title', None)
    if title:
        doc = node.ownerDocument
        p = doc.createElement('heading')
        node.parentNode.insertBefore(p, node)
        supp = editor.getMixedContentSupport(model, p)
        supp.parse(title)

node.setAttribute('type', String.inputConvert(type))
# $Id: save_helper.py,v 1.6 2005/10/05 16:21:22 guido Exp $
from Products.Silva.mangle import String
from Products.Silva.adapters.path import getPathAdapter

request = context.REQUEST
node = request.node
pad = getPathAdapter(request)

image_path = pad.urlToPath(request['path'])
node.setAttribute('path', String.inputConvert(image_path))

link_title = request['title']
node.setAttribute('title', String.inputConvert(link_title))

link = request.get('link')
link_selector = request.get('link_selector')
if link_selector == 'hiresimg_url':
    node.setAttribute('link_to_hires', '1')
    image = context.content()
    if image:
        link = '%s?hires' % '/'.join(image_path.split('/'))
else:
    node.setAttribute('link_to_hires', '0')

if link:
    if link.find(':') == -1:
        # XXX can we assume any path containing a : is a URL??
        link = pad.urlToPath(link)
    node.setAttribute('link', String.inputConvert(link))
else:
    node.removeAttribute('link')
from Products.Silva.mangle import String

request = context.REQUEST
node = request.node

node.setAttribute('type', String.inputConvert(request['element_type']))

# process all elements (note that we make a tuple of childNodes so it won't change anymore,
# even if we insert stuff)
for child in tuple(node.childNodes):
    if child.nodeType != node.ELEMENT_NODE:
        continue
    if child.nodeName == 'title': continue
    try:
        data = request[child.getNodePath('widget')]
        context.set_simple_content(child, data)
    except KeyError:
        pass
Exemple #4
0
from Products.Silva.mangle import String

if not context.check_editable():
    return context.redirect()

node = context.REQUEST.node
doc = node.ownerDocument
columns = int(node.getAttribute('columns'))
if columns <= 1:
    # can't remove column if we only have one column left
    return

for row in node.childNodes:
    if row.nodeName != 'row':
        continue
    row.removeChild(row.lastChild)

# invalidate cache
#for mode in ['mode_normal', 'mode_edit', 'mode_insert', 'mode_done']:
#    context.service_editor.invalidateCache(node,
#       ('service_document_editor_widgets', 'element', 'table', mode))

node.setAttribute('columns', String.inputConvert(str(columns - 1)))
if node.hasAttribute('column_info'):
    column_info = node.getAttribute('column_info').split()
    node.setAttribute('column_info', u' '.join(column_info[:-1]))

return context.redirect()
Exemple #5
0
if not context.check_editable():
    return context.redirect()

node = context.REQUEST.node
doc = node.ownerDocument
for row in node.childNodes:
    if row.nodeName != 'row':
        continue
    # add field
    field = doc.createElement('field')
    p = doc.createElement('p')
    p.appendChild(doc.createTextNode(''))
    field.appendChild(p)

    row.appendChild(field)

node.setAttribute(
    'columns', String.inputConvert(str(int(node.getAttribute('columns')) + 1)))

if node.hasAttribute('column_info'):
    node.setAttribute('column_info',
                      node.getAttribute('column_info') + u' L:1')

# invalidate cache
#for mode in ['mode_normal', 'mode_edit', 'mode_insert', 'mode_done']:
#    context.service_editor.invalidateCache(node,
#       ('service_document_editor_widgets', 'element', 'table', mode))

return context.redirect()
Exemple #6
0
from Products.Silva.mangle import String

request = context.REQUEST
node = request.node

node.setAttribute('type', String.inputConvert(request['element_type']))

lookup = {'left': 'L', 'center': 'C', 'right': 'R'}

columns = context.get_columns()
# process column info
column_info = []
for column in range(columns):
    key = 'column_align_%s' % column
    if request.has_key(key):
        align = lookup.get(request[key], 'L')
    else:
        align = 'L'
    key = 'column_width_%s' % column
    if request.has_key(key):
        width = request[key]
        try:
            width = int(width)
            if width < 1:
                width = 1
        except ValueError:
            width = '*'
    else:
        width = '*'

    column_info.append('%s:%s' % (align, width))
    return

# strip off trailing whitespace, so empty lines do not lead to empty listitems
data = request['data']
data = data.rstrip()

if not request.has_key('element_type'):
    element_type = 'disc'
else:
    element_type = request['element_type']

if element_type not in ['circle', 'square', 'disc', 
                        '1', 'A', 'a', 'I', 'i', 'none']:
    return

node.setAttribute('type', String.inputConvert(element_type))

# remove previous items, except for the title node
childNodes = [ child for child in  node.childNodes if child.nodeName=='li' ]
childNodes.reverse()
for child in childNodes:
    node.removeChild(child)

# now add new items
doc = node.ownerDocument

lines = data.split('\r\n')
lines = [ line.strip() for line in lines ]
data = '\r\n'.join(lines)
items = data.split('\r\n\r\n')
for item in items:
    context.element_switch()
    return

if not request.has_key('element_type'):
    element_type = 'normal'
else:
    element_type = request['element_type']

# strip off empty newlines at the end
data = request['data']
data = data.rstrip()

if element_type not in ['normal', 'compact']:
    return

node.setAttribute('type', String.inputConvert(element_type))

# remove previous items, except for the title node
childNodes = [ child 
    for child in  node.childNodes 
    if child.nodeName=='dd' or child.nodeName == 'dt']
childNodes.reverse()
for child in childNodes:
    node.removeChild(child)

# now add new items
doc = node.ownerDocument

# reduce multiple linebreaks to 2
while data.find('\r\n\r\n\r\n') > -1:
    data = data.replace('\r\n\r\n\r\n', '\r\n\r\n')
if not context.check_editable():
    return context.redirect()

node = context.REQUEST.node
doc = node.ownerDocument
for row in node.childNodes:
    if row.nodeName != 'row':
        continue
    # add field
    field = doc.createElement('field')
    p = doc.createElement('p')
    p.appendChild(doc.createTextNode(''))
    field.appendChild(p)

    row.appendChild(field)

node.setAttribute(
    'columns', 
    String.inputConvert(str(int(node.getAttribute('columns')) + 1)) )

if node.hasAttribute('column_info'):
    node.setAttribute('column_info', node.getAttribute('column_info') + u' L:1')

# invalidate cache
#for mode in ['mode_normal', 'mode_edit', 'mode_insert', 'mode_done']:
#    context.service_editor.invalidateCache(node,
#       ('service_document_editor_widgets', 'element', 'table', mode))

return context.redirect()
from Products.Silva.mangle import String

request = context.REQUEST
node = request.node
if request.has_key('path'):
    path = request['path']
else:
    path = '' 
node.setAttribute('path', String.inputConvert(path))
from Products.Silva.mangle import String

request = context.REQUEST
node = request.node
document = node.get_content()
data = String.inputConvert(request['data'])
document.set_title(data)
Exemple #12
0
from Products.Silva.mangle import String

request = context.REQUEST
node = request.node

toc_depth = request['toc_depth']
node.setAttribute('toc_depth', String.inputConvert(toc_depth))
from Products.Silva.mangle import String

request = context.REQUEST
node = request.node

node.setAttribute('type', String.inputConvert(request['element_type']))

# process all elements (note that we make a tuple of childNodes so it won't change anymore,
# even if we insert stuff)
for child in tuple(node.childNodes):
   if child.nodeType != node.ELEMENT_NODE:
       continue
   if child.nodeName == 'title': continue
   try:
       data = request[child.getNodePath('widget')]
       context.set_simple_content(child, data)
   except KeyError:
       pass
from Products.Silva.mangle import String

request = context.REQUEST
node = request.node
if request.has_key('path'):
    path = request['path']
else:
    path = ''
node.setAttribute('path', String.inputConvert(path))
editorsupport = context.service_editorsupport

model = node.get_content()

if request['what'] != 'p':
    context.element_switch()
    return

data = request['data']
type = request['element_type']

# split into number of text items
lines = data.split('\r\n')
lines = [ line.strip() for line in lines ]
data = '\r\n'.join(lines)
items = data.split('\r\n\r\n')
# replace text in node
supp = editorsupport.getMixedContentSupport(model, node)
supp.parse(items[0])
# if necessary, add new paragraphs
if len(items) > 1:
    doc = node.ownerDocument
    next = node.nextSibling
    for item in items[1:]:
        p = doc.createElement('p')
        node.parentNode.insertBefore(p, next)
        supp = editorsupport.getMixedContentSupport(model, p)
        supp.parse(item)

node.setAttribute('type', String.inputConvert(type))
from Products.Silva.mangle import String

request = context.REQUEST
node = request.node

node.setAttribute('type', String.inputConvert(request['element_type']))

lookup = {'left':'L', 'center':'C', 'right':'R'}

columns = context.get_columns()
# process column info
column_info = []
for column in range(columns):
    key = 'column_align_%s' % column
    if request.has_key(key):
       align = lookup.get(request[key], 'L')
    else:
       align = 'L'
    key = 'column_width_%s' % column
    if request.has_key(key):
       width = request[key]
       try:
         width = int(width)
         if width < 1:
             width = 1
       except ValueError:
         width = '*'
    else:
       width = '*'
       
    column_info.append('%s:%s' % (align, width))