[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/File/Views/Browser - I18nFileEdit.py:1.1 I18nFileView.py:1.1 i18n_edit.pt:1.1 configure.zcml:1.9
Marius Gedminas
mgedmin@delfi.lt
Mon, 24 Jun 2002 11:44:26 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/File/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv8178/lib/python/Zope/App/OFS/Content/File/Views/Browser
Modified Files:
configure.zcml
Added Files:
I18nFileEdit.py I18nFileView.py i18n_edit.pt
Log Message:
Added I18nFile.
=== Added File Zope3/lib/python/Zope/App/OFS/Content/File/Views/Browser/I18nFileEdit.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
Revision information:
$Id: I18nFileEdit.py,v 1.1 2002/06/24 15:44:25 mgedmin Exp $
"""
from Zope.Publisher.Browser.BrowserView import BrowserView
from Zope.App.PageTemplate import ViewPageTemplateFile
class I18nFileEdit(BrowserView):
__implements__ = BrowserView.__implements__
name = 'editForm'
title = 'Edit Form'
description = ('This edit form allows you to make changes to the ' +
'properties of this file.')
template = ViewPageTemplateFile('i18n_edit.pt')
def action(self, contentType, data, language, defaultLanguage,
selectLanguage=None, removeLanguage=None,
addLanguage=None, newLanguage=None):
if selectLanguage:
pass
elif removeLanguage:
self.context.removeLanguage(language)
language = self.context.getDefaultLanguage()
else:
if addLanguage:
language = newLanguage
self.context.setDefaultLanguage(defaultLanguage)
self.context.edit(data, contentType, language)
return self.request.response.redirect(self.request.URL[-1] +
"/editForm.html?language=%s" % language) # XXX url_quote
=== Added File Zope3/lib/python/Zope/App/OFS/Content/File/Views/Browser/I18nFileView.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id: I18nFileView.py,v 1.1 2002/06/24 15:44:25 mgedmin Exp $
"""
from Zope.Publisher.Browser.BrowserView import BrowserView
from Zope.I18n.Negotiator import negotiator
class I18nFileView(BrowserView):
def __call__(self):
"""Call the File"""
request = self.request
language = None
if request is not None:
langs = self.context.getAvailableLanguages()
language = negotiator.getLanguage(langs, request)
request.response.setHeader('Content-Type',
self.context.getContentType())
request.response.setHeader('Content-Length',
self.context.getSize(language))
return self.context.getData(language)
=== Added File Zope3/lib/python/Zope/App/OFS/Content/File/Views/Browser/i18n_edit.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<style metal:fill-slot="headers" type="text/css">
<!--
.ContentIcon {
width: 20px;
}
.ContentTitle {
text-align: left;
}
-->
</style>
</head>
<body>
<div metal:fill-slot="body">
<p tal:content="context/msg"
tal:condition="python: hasattr(context, 'msg')">
Message will go here.
</p>
<p tal:content="view/description">
Description of the Form.
</p>
<form action="edit.html" method="post">
<table class="EditTable">
<tbody>
<tr>
<th class="EditAttributeName">Content Type</th>
<td class="EditAttributeValue">
<input name="contentType" type="text" size=20
tal:attributes="value context/getContentType" />
</tr>
<tr>
<th class="EditAttributeName">Default Language</th>
<td class="EditAttributeValue">
<select name="defaultLanguage">
<span tal:repeat="lang context/getAvailableLanguages"
tal:omit-tag="">
<option selected
tal:attributes="value lang"
tal:condition="python:context.getDefaultLanguage() == lang"
tal:content="lang" />
<option
tal:attributes="value lang"
tal:condition="python:context.getDefaultLanguage() != lang"
tal:content="lang" />
</span>
</select>
</tr>
<tr>
<td colspan=2>
<hr>
</td>
</tr>
<tr>
<th class="EditAttributeName">Language</th>
<td class="EditAttributeValue">
<select name="language">
<span tal:repeat="lang context/getAvailableLanguages"
tal:omit-tag="">
<option selected
tal:attributes="value lang"
tal:condition="python:request.get('language',
context.getDefaultLanguage()) == lang"
tal:content="lang" />
<option
tal:attributes="value lang"
tal:condition="python:request.get('language',
context.getDefaultLanguage()) != lang"
tal:content="lang" />
</span>
</select>
<input type="submit" name="selectLanguage"
value="Show" />
<input type="submit" name="removeLanguage"
value="Remove" />
<input type="submit" name="addLanguage"
value="Add new language" />
<input type="text" name="newLanguage" size=10 />
</tr>
<tr>
<th class="EditAttributeName">Data</th>
<td class="EditAttributeValue">
<textarea name="data" cols=70 rows=10
tal:content="python:context.getData(request.get('language'))">
</textarea>
</tr>
</tbody>
</table>
<input type="submit" name="edit" value="Save Changes" />
</form>
</div>
</body>
</html>
=== Zope3/lib/python/Zope/App/OFS/Content/File/Views/Browser/configure.zcml 1.8 => 1.9 ===
<!-- File View Directives -->
- <browser:defaultView
+ <browser:view
name="view"
for=".IFile."
permission="Zope.View"
factory=".Views.Browser.FileView." />
+ <browser:defaultView
+ for=".IFile."
+ name="view" />
+
<browser:view
for=".IFile."
permission="Zope.View"
@@ -21,6 +25,22 @@
<browser:page name="edit.html" attribute="action" />
</browser:view>
+ <browser:view
+ name="view"
+ for=".I18nFile.II18nFile."
+ permission="Zope.View"
+ factory=".Views.Browser.I18nFileView." />
+
+ <browser:view
+ for="Zope.App.OFS.Content.File.I18nFile.II18nFile."
+ permission="Zope.View"
+ factory=".Views.Browser.I18nFileEdit.">
+
+ <browser:page name="editForm.html" template="Views/Browser/i18n_edit.pt" />
+ <browser:page name="edit.html" attribute="action" />
+ </browser:view>
+
+
<!-- Registering all the field views for the browser -->
<browser:view
@@ -45,6 +65,10 @@
<browser:menuItem menu="add_content"
for="Zope.App.OFS.Container.IAdding."
title="File" action="File" />
+
+ <browser:menuItem menu="add_content"
+ for="Zope.App.OFS.Container.IAdding."
+ title="I18n File" action="I18nFile" />
<browser:menuItem menu="add_content"
for="Zope.App.OFS.Container.IAdding."