<?xml version="1.0"?>
<ZopeData>
  <record id="1" aka="AAAAAAAAAAE=">
    <pickle>
      <tuple>
        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
        <tuple/>
      </tuple>
    </pickle>
    <pickle>
      <dictionary>
        <item>
            <key> <string>Script_magic</string> </key>
            <value> <int>3</int> </value>
        </item>
        <item>
            <key> <string>_bind_names</string> </key>
            <value>
              <object>
                <klass>
                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
                </klass>
                <tuple/>
                <state>
                  <dictionary>
                    <item>
                        <key> <string>_asgns</string> </key>
                        <value>
                          <dictionary>
                            <item>
                                <key> <string>name_container</string> </key>
                                <value> <string>container</string> </value>
                            </item>
                            <item>
                                <key> <string>name_context</string> </key>
                                <value> <string>context</string> </value>
                            </item>
                            <item>
                                <key> <string>name_m_self</string> </key>
                                <value> <string>script</string> </value>
                            </item>
                            <item>
                                <key> <string>name_subpath</string> </key>
                                <value> <string>traverse_subpath</string> </value>
                            </item>
                          </dictionary>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>_body</string> </key>
            <value> <string encoding="cdata"><![CDATA[

"""\n
Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.\n
            Thomas Bernard   <thomas@nexedi.com>\n
\n
This program is Free Software; you can redistribute it and/or\n
modify it under the terms of the GNU General Public License\n
as published by the Free Software Foundation; either version 2\n
of the License, or (at your option) any later version.\n
\n
This program is distributed in the hope that it will be useful,\n
but WITHOUT ANY WARRANTY; without even the implied warranty of\n
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n
GNU General Public License for more details.\n
\n
You should have received a copy of the GNU General Public License\n
along with this program; if not, write to the Free Software\n
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n
"""\n
\n
"""\n
This script is aimed to generate the CSS code needed to display correctly the\n
PlanningBox in HTML style (i.e using HTML code + CSS class for positionning).\n
The process is based on the strucutre passed in parameter (i.e \'structure\').\n
\n
Beware this only generates CSS code, and need to use the \'planning_coordinates\'\n
script (\'planning_css\') to have CSS compliant code, no HTML generation is\n
done in this script.\n
"""\n
properties_structure = context.planning_coordinates(basic, planning)\n
"""\n
- the properties_structure returned from the planning_coordinates script is somehow\n
special : it is a dict defined by the areas of data\n
- then each area is itself a dict defined by the name of the object (axis, group, block, etc.)\n
- finally the objects holds a dict with all the proprieties\n
"""\n
\n
\n
# udating properties if necessary.\n
# This process is only usefull when displaying a planning that failed to\n
# validate. In such a case the block properties are updated to match their\n
# last position.\n
block_string = basic.REQUEST.get(\'previous_block_moved\',\'\')\n
if block_string != \'\':\n
  # block_list is not empty, need to recover porperties and update the blocks\n
  # that need to be refreshed\n
  block_object_list = block_string.split(\'*\')\n
  for block_object_string in block_object_list:\n
    block_dict = None\n
    block_dict = {}\n
    block_sub_list = block_object_string.split(\',\')\n
    block_dict[\'name\'] = block_sub_list[0]\n
    block_dict[\'old_X\'] = float(block_sub_list[1])\n
    block_dict[\'old_Y\'] = float(block_sub_list[2])\n
    block_dict[\'new_X\'] = float(block_sub_list[3])\n
    block_dict[\'new_Y\'] = float(block_sub_list[4])\n
    block_dict[\'width\'] = float(block_sub_list[5])\n
    block_dict[\'height\'] = float(block_sub_list[6])\n
    # recovering corresponding block coordinates object in properties_structure\n
    block_properties = properties_structure[\'content\'][block_dict[\'name\']]\n
    # list of dict of blocks has been recovered\n
    # need to find deltaX and deltaY\n
    deltaX = block_dict[\'old_X\'] - block_properties[\'margin-left\']\n
    deltaY = block_dict[\'old_Y\'] - block_properties[\'margin-top\']\n
    # updating position\n
    block_properties[\'margin-left\'] = block_dict[\'new_X\'] - deltaX\n
    block_properties[\'margin-top\'] = block_dict[\'new_Y\'] - deltaY\n
    # updating size\n
    block_properties[\'width\']  = block_dict[\'width\']\n
    block_properties[\'height\'] = block_dict[\'height\']\n
\n
else:\n
  # no unvalidated block, using actual properties\n
  pass\n
\n
# build list from dictionnary structure\n
# this list will e converted to a string afterwards\n
returned_list = []\n
for area_name in properties_structure.keys():\n
  css_dict = properties_structure[area_name]\n
  for class_name in css_dict.keys():\n
    if class_name == \'planning_content\':\n
      returned_list.append(\'.%s{\' % class_name)\n
    elif class_name == \'planning_box\':\n
      returned_list.append(\'.%s{\' % class_name)\n
    else:\n
      returned_list.append(\'#%s{\' % class_name)\n
    for id in css_dict[class_name].keys():\n
      if same_type(css_dict[class_name][id],\'\'):\n
        returned_list.append(\'%s:%s;\\n\' % (id,css_dict[class_name][id]))\n
      else:\n
        # if data is type float or integer then need to add \'px\' at the end\n
        returned_list.append(\'%s:%s%s;\\n\' % (id, int(css_dict[class_name][id] + 0.5),\'px\'))\n
    returned_list.append(\'}\\n\')\n
returned_list.append(" \\\n
.planning_box_topleft{ position:absolute;left:0;top:0;} \\n \\\n
.planning_box_topright{position:absolute;right:0;top:0;} \\n \\\n
.planning_box_botleft{ position:absolute;bottom:0;left:0;} \\n \\\n
.planning_box_botright{position:absolute;right:0;bottom:0;} \\n \\\n
.planning_box_center{position:absolute; left:0; right:0; top:40%;}")\n
\n
\n
# now joining list to build the final CSS string\n
# and returning it\n
return "\\n" + "".join(returned_list)\n


]]></string> </value>
        </item>
        <item>
            <key> <string>_code</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>basic=None, planning=None</string> </value>
        </item>
        <item>
            <key> <string>errors</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
        <item>
            <key> <string>func_code</string> </key>
            <value>
              <object>
                <klass>
                  <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
                </klass>
                <tuple/>
                <state>
                  <dictionary>
                    <item>
                        <key> <string>co_argcount</string> </key>
                        <value> <int>2</int> </value>
                    </item>
                    <item>
                        <key> <string>co_varnames</string> </key>
                        <value>
                          <tuple>
                            <string>basic</string>
                            <string>planning</string>
                            <string>_getattr_</string>
                            <string>context</string>
                            <string>properties_structure</string>
                            <string>block_string</string>
                            <string>block_object_list</string>
                            <string>_getiter_</string>
                            <string>block_object_string</string>
                            <string>None</string>
                            <string>block_dict</string>
                            <string>block_sub_list</string>
                            <string>_getitem_</string>
                            <string>_write_</string>
                            <string>float</string>
                            <string>block_properties</string>
                            <string>deltaX</string>
                            <string>deltaY</string>
                            <string>returned_list</string>
                            <string>area_name</string>
                            <string>css_dict</string>
                            <string>class_name</string>
                            <string>id</string>
                            <string>same_type</string>
                            <string>int</string>
                          </tuple>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>func_defaults</string> </key>
            <value>
              <tuple>
                <none/>
                <none/>
              </tuple>
            </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>planning_css</string> </value>
        </item>
        <item>
            <key> <string>warnings</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
