Commit 35763182 authored by Romain Courteaud's avatar Romain Courteaud

Add license header.

Update layout.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19467 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f15c6df1
def ERP5Site_createModuleScribus(self, ##############################################################################
module_id=None, #
module_portal_type=None, # Copyright (c) 2008 Nexedi SA and Contributors. All Rights Reserved.
module_title=None, #
import_pdf_file=None, # WARNING: This program as such is intended to be used by professional
import_scribus_file=None, # programmers who take the whole responsability of assessing all potential
option_html=None, # consequences resulting from its eventual inadequacies and bugs
desired_width=None, # End users who are looking for a ready-to-use solution with commercial
desired_height=None, # garantees and support are strongly adviced to contract a Free Software
object_title=None, # Service Company
object_portal_type=None, #
portal_skins_folder=None, # This program is Free Software; you can redistribute it and/or
form_id=None, # modify it under the terms of the GNU General Public License
selection_index=None, # as published by the Free Software Foundation; either version 2
selection_name=None, # of the License, or (at your option) any later version.
**kw): #
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
def ERP5Site_createModuleScribus(self,
module_id=None,
module_portal_type=None,
module_title=None,
import_pdf_file=None,
import_scribus_file=None,
option_html=None,
desired_width=None,
desired_height=None,
object_title=None,
object_portal_type=None,
portal_skins_folder=None,
form_id=None,
selection_index=None,
selection_name=None,
**kw):
""" Creates a module, portal_type and ERP5Form from a scribus and """ Creates a module, portal_type and ERP5Form from a scribus and
PDFForm file""" PDFForm file"""
context = self context = self
# IMPORTING MODULES # IMPORTING MODULES
from Products.Formulator.Errors import ValidationError, FormValidationError from Products.Formulator.Errors import ValidationError, FormValidationError
from Products.ERP5Form.ScribusUtils import ScribusParser from Products.ERP5Form.ScribusUtils import ScribusParser
...@@ -77,18 +103,18 @@ def ERP5Site_createModuleScribus(self, ...@@ -77,18 +103,18 @@ def ERP5Site_createModuleScribus(self,
# return the skin_folder object # return the skin_folder object
skin_folder = ManageModule.setSkinFolder(portal, skin_folder = ManageModule.setSkinFolder(portal,
portal_skins_folder) portal_skins_folder)
# ERP FORM LIST PROCESSING # ERP FORM LIST PROCESSING
# Create ERP5 Form in order to view the module # Create ERP5 Form in order to view the module
# set up the factory based on skin_folder # set up the factory based on skin_folder
factory = skin_folder.manage_addProduct['ERP5Form'] factory = skin_folder.manage_addProduct['ERP5Form']
# run the factory to create the new object (ERP5Form) # run the factory to create the new object (ERP5Form)
ManageFiles.setERP5Form(factory, ManageFiles.setERP5Form(factory,
str(object_names['view_list']), str(object_names['view_list']),
str(object_title + ' Module View')) '%s Module View' % object_title)
# manage the module form and set up the list inside # manage the module form and set up the list inside
# update form properties with generic module values # update form properties with generic module values
# and implement the objects' listing inside the form # and implement the objects' listing inside the form
...@@ -98,7 +124,7 @@ def ERP5Site_createModuleScribus(self, ...@@ -98,7 +124,7 @@ def ERP5Site_createModuleScribus(self,
module_title, module_title,
module_id, module_id,
def_lineNumberInList) def_lineNumberInList)
# INIT ATTRIBUTES DICT # INIT ATTRIBUTES DICT
# global_properties is a special dict destinated to # global_properties is a special dict destinated to
...@@ -106,9 +132,8 @@ def ERP5Site_createModuleScribus(self, ...@@ -106,9 +132,8 @@ def ERP5Site_createModuleScribus(self,
# parsing, allowing them to be updated when needed # parsing, allowing them to be updated when needed
# and used if necessary. # and used if necessary.
global_properties = ScribusParser.initFieldDict() global_properties = ScribusParser.initFieldDict()
# PARSER VARIABLES DECLARATION # PARSER VARIABLES DECLARATION
# the following variable will recover the final CSS # the following variable will recover the final CSS
# file's content object (string) before saving it # file's content object (string) before saving it
...@@ -118,7 +143,7 @@ def ERP5Site_createModuleScribus(self, ...@@ -118,7 +143,7 @@ def ERP5Site_createModuleScribus(self,
properties_css_dict = {} properties_css_dict = {}
# init page number # init page number
page_number_int = 0 page_number_int = 0
scale_factor=0 scale_factor = 0
# import scribus file # import scribus file
# take the input ScribusFile and read the content # take the input ScribusFile and read the content
xml_string = ScribusParser.getContentFile(import_scribus_file) xml_string = ScribusParser.getContentFile(import_scribus_file)
...@@ -126,11 +151,11 @@ def ERP5Site_createModuleScribus(self, ...@@ -126,11 +151,11 @@ def ERP5Site_createModuleScribus(self,
print "no field was defined in the Scribus file" print "no field was defined in the Scribus file"
pass pass
else: else:
# GETTING FULL SCRIBUS DOCUMENT PROPERTIES # GETTING FULL SCRIBUS DOCUMENT PROPERTIES
# get string from ScribusFile content # get string from ScribusFile content
output_string = str(xml_string) output_string = str(xml_string)
print " createmodule > ScribusParser.getXmlObjectPropertiesDict" print " createmodule > ScribusParser.getXmlObjectPropertiesDict"
# building a tree from the output string elaborated from the # building a tree from the output string elaborated from the
# original Scribus file. # original Scribus file.
...@@ -141,24 +166,24 @@ def ERP5Site_createModuleScribus(self, ...@@ -141,24 +166,24 @@ def ERP5Site_createModuleScribus(self,
# unnecessary page_objects off. # unnecessary page_objects off.
#import pdb #import pdb
#pdb.set_trace() #pdb.set_trace()
(text_field_list,keep_page,page_gap) = ScribusParser.getXmlObjectsPropertiesDict(xml_string) (text_field_list, keep_page, page_gap) = \
ScribusParser.getXmlObjectsPropertiesDict(xml_string)
print " createmodule < ScribusParser.getXmlObjectPropertiesDict\n" print " createmodule < ScribusParser.getXmlObjectPropertiesDict\n"
print " createmodule > ScribusParser.getPropertiesConversionDict" print " createmodule > ScribusParser.getPropertiesConversionDict"
# parsing text_field_list created from the getXmlObjectsPropertiesDict # parsing text_field_list created from the getXmlObjectsPropertiesDict
# to extract all the usefull properties and organize elements. Then check # to extract all the usefull properties and organize elements. Then check
# attributes to get properties values. # attributes to get properties values.
# This represents the main process of the script. # This represents the main process of the script.
(widget_properties) = ScribusParser.getPropertiesConversionDict(text_field_list) widget_properties = \
ScribusParser.getPropertiesConversionDict(text_field_list)
print " createmodule < ScribusParser.getPropertiesConversionDict\n" print " createmodule < ScribusParser.getPropertiesConversionDict\n"
# testing if final rendering is PDF-like # testing if final rendering is PDF-like
if option_html == 1 : if option_html == 1:
print " createmodule > generating background" print " createmodule > generating background"
## BACKGROUND GENERATOR ## BACKGROUND GENERATOR
# extract background pictures from the PDF document, convert them in the right # extract background pictures from the PDF document, convert them in the right
...@@ -166,15 +191,15 @@ def ERP5Site_createModuleScribus(self, ...@@ -166,15 +191,15 @@ def ERP5Site_createModuleScribus(self,
# used only with option_html == 1 # used only with option_html == 1
# recover image_size # recover image_size
image_size = ManageFiles.setBackgroundPictures(import_pdf_file, image_size = ManageFiles.setBackgroundPictures(import_pdf_file,
object_names,skin_folder,desired_height,desired_width,resolution, object_names, skin_folder, desired_height, desired_width,
background_format) resolution, background_format)
page_width, page_height = image_size page_width, page_height = image_size
print " height = " + str(page_height) print " height = " + str(page_height)
print " width = " + str(page_width) print " width = " + str(page_width)
print " createmodule < background generated\n" print " createmodule < background generated\n"
# add field from OrderedWidgetProperties in ERP5 Module created # add field from OrderedWidgetProperties in ERP5 Module created
# radiofield_widget_properties = {} # radiofield_widget_properties = {}
position = {} position = {}
...@@ -182,7 +207,7 @@ def ERP5Site_createModuleScribus(self, ...@@ -182,7 +207,7 @@ def ERP5Site_createModuleScribus(self,
personal_properties_list = [] personal_properties_list = []
# recovering number of pages # recovering number of pages
global_properties['page'] = len(widget_properties) global_properties['page'] = len(widget_properties)
# CSS FILE INIT # CSS FILE INIT
# init the CSS dict by creating sub-dicts to store various information # init the CSS dict by creating sub-dicts to store various information
...@@ -204,17 +229,17 @@ def ERP5Site_createModuleScribus(self, ...@@ -204,17 +229,17 @@ def ERP5Site_createModuleScribus(self,
# get CSS class properties relative to the actual page # get CSS class properties relative to the actual page
# (background picture position, picture size, etc.) # (background picture position, picture size, etc.)
# and add them to the css dict # and add them to the css dict
width_groups,height_groups = ManageFiles.getPageattributes( width_groups, height_groups = ManageFiles.getPageattributes(
global_properties, global_properties,
import_pdf_file) import_pdf_file)
properties_css_dict, properties_page = \ properties_css_dict, properties_page = \
ManageCSS.setPageProperties( properties_css_dict, ManageCSS.setPageProperties(properties_css_dict,
page_iterator, page_iterator,
page_id, page_id,
page_height, page_height,
page_width, page_width,
width_groups, width_groups,
height_groups) height_groups)
# RESUME DATA INTERPRETATION # RESUME DATA INTERPRETATION
# iterating pageobjects in page # iterating pageobjects in page
...@@ -254,16 +279,14 @@ def ERP5Site_createModuleScribus(self, ...@@ -254,16 +279,14 @@ def ERP5Site_createModuleScribus(self,
# add last properties to css dict, including implementation # add last properties to css dict, including implementation
# of a n+1 page to prevent bug when rendering under Konqueror # of a n+1 page to prevent bug when rendering under Konqueror
ManageCSS.setFinalProperties(properties_css_dict,page_height, ManageCSS.setFinalProperties(properties_css_dict, page_height,
space_between_pages) space_between_pages)
# generate output string from dict # generate output string from dict
form_css_content = ManageCSS.generateOutputContent(properties_css_dict) form_css_content = ManageCSS.generateOutputContent(properties_css_dict)
# save CSS string content into ERP5 # save CSS string content into ERP5
ManageFiles.setCSSFile(factory,object_names['css'],form_css_content) ManageFiles.setCSSFile(factory, object_names['css'], form_css_content)
# CREATING OBJECT FORM AND MANAGING GROUPS # CREATING OBJECT FORM AND MANAGING GROUPS
...@@ -284,18 +307,18 @@ def ERP5Site_createModuleScribus(self, ...@@ -284,18 +307,18 @@ def ERP5Site_createModuleScribus(self,
# create fields corresponding to the page_objects # create fields corresponding to the page_objects
# recovered from the scribus file # recovered from the scribus file
ManageModule.setFieldsInObjectForm(skin_folder, ManageModule.setFieldsInObjectForm(skin_folder,
object_names, object_names,
default_groups, default_groups,
global_properties, global_properties,
option_html option_html
) )
print " createmodule < fields created in ERP5 Form\n" print " createmodule < fields created in ERP5 Form\n"
# PDF IMPORTATION AND TALES GENERATION # PDF IMPORTATION AND TALES GENERATION
print " createmodule > managing PDF settings" print " createmodule > managing PDF settings"
# read all the content of the PDF document and save it in the skin_folder # read all the content of the PDF document and save it in the skin_folder
...@@ -305,14 +328,14 @@ def ERP5Site_createModuleScribus(self, ...@@ -305,14 +328,14 @@ def ERP5Site_createModuleScribus(self,
skin_folder, skin_folder,
object_names, object_names,
object_title, object_title,
pdf_file = import_pdf_file pdf_file=import_pdf_file
) )
print " createmodule < PDF settings managed\n" print " createmodule < PDF settings managed\n"
# PROPERTYSHEET AND DOCUMENT CREATION # PROPERTYSHEET AND DOCUMENT CREATION
print " createmodule > PropertySheet and Document creation" print " createmodule > PropertySheet and Document creation"
# recover personal properties and save them in a PropertySheet # recover personal properties and save them in a PropertySheet
# then create the Document related to the object # then create the Document related to the object
...@@ -328,9 +351,7 @@ def ERP5Site_createModuleScribus(self, ...@@ -328,9 +351,7 @@ def ERP5Site_createModuleScribus(self,
from Products.ERP5Type.Utils import initializeLocalDocumentRegistry from Products.ERP5Type.Utils import initializeLocalDocumentRegistry
initializeLocalDocumentRegistry() initializeLocalDocumentRegistry()
print " createmodule < PropertySheet and Document imported\n" print " createmodule < PropertySheet and Document imported\n"
# OBJECT PORTAL TYPE # OBJECT PORTAL TYPE
# create PortalType for the object # create PortalType for the object
...@@ -340,8 +361,7 @@ def ERP5Site_createModuleScribus(self, ...@@ -340,8 +361,7 @@ def ERP5Site_createModuleScribus(self,
object_names object_names
) )
# Finally add the module to the site # Finally add the module to the site
ManageModule.registerModule(portal, ManageModule.registerModule(portal,
module_id, module_id,
...@@ -352,15 +372,15 @@ def ERP5Site_createModuleScribus(self, ...@@ -352,15 +372,15 @@ def ERP5Site_createModuleScribus(self,
# manage redirection URL # manage redirection URL
if not selection_index: if not selection_index:
redirect_url = '%s/view?%s' % ( portal.absolute_url() redirect_url = '%s/view?%s' % (portal.absolute_url(),
, 'portal_status_message=Module+Created.' 'portal_status_message=Module+Created.'
) )
else: else:
redirect_url = '%s/view?selection_index=%s&selection_name=%s&%s' % ( redirect_url = '%s/view?selection_index=%s&selection_name=%s&%s' % (
portal.absolute_url() portal.absolute_url(),
, selection_index selection_index,
, selection_name selection_name,
, 'portal_status_message=Module+Created.' 'portal_status_message=Module+Created.'
) )
# redirect # redirect
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment