[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/Folder/Views/XUL - Main.py:1.1.4.1 SetLimit.py:1.1.4.1 Tree.py:1.1.4.1 __init__.py:1.1.4.1 action.pt:1.1.4.1 limit.pt:1.1.4.1 main.pt:1.1.4.1 menu.pt:1.1.4.1 tree.pt:1.1.4.1 xmlrpclib.pt:1.1.4.1 xul.zcml:1.1.4.1

Christian Theune ct@gocept.com
Sat, 18 May 2002 13:02:29 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/Folder/Views/XUL
In directory cvs.zope.org:/tmp/cvs-serv3937/lib/python/Zope/App/OFS/Content/Folder/Views/XUL

Added Files:
      Tag: Zope-3x-branch
	Main.py SetLimit.py Tree.py __init__.py action.pt limit.pt 
	main.pt menu.pt tree.pt xmlrpclib.pt xul.zcml 
Log Message:
Completing OFS.Folder -> OFS.Content.Folder by merging 'ctheune-foldermove-branch' into Zope-3x-branch

=== Added File Zope3/lib/python/Zope/App/OFS/Content/Folder/Views/XUL/Main.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: Main.py,v 1.1.4.1 2002/05/18 17:02:27 ctheune Exp $
"""


from Zope.PageTemplate.PageTemplateFile import PageTemplateFile
from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
from Zope.App.OFS.IContainer import IReadContainer

class Main(AttributePublisher):
    """ """

    __implements__ = AttributePublisher.__implements__


    def __init__(self, context):
        """Initialize form.
        """
        self._context = context


    def getContext(self):
        """ """
        return self._context


    index = PageTemplateFile('main.pt')
    menu = PageTemplateFile('menu.pt')



=== Added File Zope3/lib/python/Zope/App/OFS/Content/Folder/Views/XUL/SetLimit.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: SetLimit.py,v 1.1.4.1 2002/05/18 17:02:27 ctheune Exp $
"""

from Zope.App.Formulator.Form import Form
from Zope.PageTemplate.PageTemplateFile import PageTemplateFile


class SetLimit(Form):

    __implements__ = (Form.__implements__,)

    name = 'limitForm'     
    title = 'Folder Item Limit Form'
    description = ('This edit form allows you to ...')

    _fieldViewNames = ['XULLimitFieldView']

    template = PageTemplateFile('limit.pt')
    action_js = PageTemplateFile('action.pt')

    def action(self, limit):
        ''' '''
        self.getContext().setLimit(int(limit))


=== Added File Zope3/lib/python/Zope/App/OFS/Content/Folder/Views/XUL/Tree.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: Tree.py,v 1.1.4.1 2002/05/18 17:02:27 ctheune Exp $
"""


from Zope.PageTemplate.PageTemplateFile import PageTemplateFile
from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
from Zope.App.OFS.IContainer import IReadContainer

class Tree(AttributePublisher):
    """ """

    __implements__ = AttributePublisher.__implements__


    def __init__(self, context):
        """Initialize form.
        """
        self._context = context


    def _makeSubTree(self, base, prefix=''):
        """ """
        rdf = ''
        local_links = ''
        for item in base.objectItems():

            # first we need to create the meta data for this item
            fillIn = {'id': item[0],
                      'rdf_url': prefix + ':' + item[0]}
            rdf += _node_description %fillIn + '\n\n'

            # now we add the link to the base
            local_links += '''<RDF:li resource="urn:explorer%(rdf_url)s"/>\n''' %fillIn

            if IReadContainer.isImplementedBy(item[1]):
                rdf += self._makeSubTree(item[1], fillIn['rdf_url'])

        fillIn = {'links': local_links,
                  'rdf_url': prefix}
        if prefix and local_links:
            rdf += _folder_node_links %fillIn
        elif not prefix and local_links:
            rdf += _root_folder_node_links %local_links
            
        return rdf


    def getRDFTree(self, REQUEST=None):
        ''' '''
        rdf  = _rdf_start
        rdf +=  self._makeSubTree(self.getContext(), '')
        rdf += _rdf_end
        REQUEST.response.setHeader('Content-Type', 'text/xml')
        return rdf


    def getContext(self):
        """ """
        return self._context



_rdf_start = '''<?xml version="1.0"?>

<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:explorer="http://www.zope.org/rdf#">
'''

_rdf_end = '''
</RDF:RDF>
'''

_node_description = '''
  <RDF:Description about="urn:explorer%(rdf_url)s">
    <explorer:name>%(id)s</explorer:name>
  </RDF:Description>      
'''


_folder_node_links = '''
   <RDF:Seq about="urn:explorer%(rdf_url)s">
     %(links)s
   </RDF:Seq>        
'''

_root_folder_node_links = '''
   <RDF:Seq about="urn:explorer:data">
        %s
    </RDF:Seq>                                    
'''









=== Added File Zope3/lib/python/Zope/App/OFS/Content/Folder/Views/XUL/__init__.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.
# 
##############################################################################


=== Added File Zope3/lib/python/Zope/App/OFS/Content/Folder/Views/XUL/action.pt ===

// Passed in as the response handler in the asynchronous case
// and called directly (see below) in the synchronous case
function oncompletion(resp, call, status) { 
  if (status != 0) {
    alert("Error completion: " + status);
    return true;
  }

  // Was there a SOAP fault in the response?
  if (resp.fault != null) {
    var f = resp.fault;
    var detail = f.detail;
    var ds = new XMLSerializer();
    var detailStr = detail ? ds.serializeToString(detail) : "";
    alert("Fault namespace: " + f.faultNamespaceURI + "\nFault code: " + 
          f.faultCode + "\nFault string: " + f.faultString + 
          "\nFault actor: "  + f.faultActor + "\nDetail: " + detailStr);
  }
  else {
    var ret = resp.getParameters(true, {})[0];
    var val = ret.value;
    var retStr = "Success:\nName: " + ret.name + "\nValue: " + val;
    alert(retStr);
  }
  return true;
}

function action(limit) {
  var s = new SOAPCall();
  s.transportURI = "http://physics.cbu.edu:8082/loaded/methods;view/";
  s.verifySourceHeader = true;
  if (!s.verifySourceHeader)
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");

  var p1 = new SOAPParameter(parseInt(limit), "limit");
  s.encode(0, "setLimit", "http://physics.cbu.edu:8082/loaded/methods;view/", 0, null, 1, new Array(p1));
  s.invoke();

  s.encode(0, "getLimit", "http://physics.cbu.edu:8082/loaded/methods;view/", 0, null, 0, new Array());
  var r = s.invoke();
  oncompletion(r, s, 0);
 
}


=== Added File Zope3/lib/python/Zope/App/OFS/Content/Folder/Views/XUL/limit.pt ===
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<tal:dummy
  replace="python:request.response.setHeader('content-type', 'application/vnd.mozilla.xul+xml')" />

<window id="id-window"
    	title="Window Title"
    	orient="vertical"
	xmlns:html="http://www.w3.org/1999/xhtml"
    	xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        tal:attributes="id string:${view/name}-window;
                        title view/title">

  <script src="http://physics.cbu.edu:8080/loaded/limit_xul;view/action_js" />

  <description tal:content="view/description">
    Form Description
  </description>

  <box tal:repeat="fieldView python:view.getFieldViews(request)">
    <label control="some-text" value="Label"
           tal:attributes="value python: fieldView.getContext().getValue('title')" />
    <textbox tal:replace="structure fieldView/render" />
  </box>

  <button id="limitaction" class="dialog" label="Change"
          onclick="action(document.getElementById('field_limit').value)" />

</window>



=== Added File Zope3/lib/python/Zope/App/OFS/Content/Folder/Views/XUL/main.pt ===
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<tal:dummy
  replace="python:request.response.setHeader('content-type', 'application/vnd.mozilla.xul+xml')" />

<window id="id-window"
    	title="Window Title"
    	orient="vertical"
	xmlns:html="http://www.w3.org/1999/xhtml"
    	xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
>

  <hbox height="600">
    <iframe id="tabs" src="main_xul;view/menu"/>
    <splitter collapse="before" resizeafter="farthest">
      <spacer flex="1"/>
      <grippy/>
      <spacer flex="1"/>
    </splitter>
    <iframe flex="1" id="content" src="limit_xul;view"/>
  </hbox>


</window>


=== Added File Zope3/lib/python/Zope/App/OFS/Content/Folder/Views/XUL/menu.pt ===
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<tal:dummy
  replace="python:request.response.setHeader('content-type', 'application/vnd.mozilla.xul+xml')" />

<window id="id-window"
    	title="Window Title"
    	orient="vertical"
	xmlns:html="http://www.w3.org/1999/xhtml"
    	xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
>

<box width="150" height="600">
  <tree>
    <treechildren id="menuItems" flex="1">
      <treeitem tal:repeat="view views/ZMIUtility/getZMIViews">
        <treerow>
          <treecell label="Menu Item "
            tal:attributes="label view/label"/>
        </treerow>
      </treeitem>
    </treechildren>
  </tree>
</box>

</window>


=== Added File Zope3/lib/python/Zope/App/OFS/Content/Folder/Views/XUL/tree.pt ===
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<tal:dummy
  replace="python:request.response.setHeader('content-type', 'application/vnd.mozilla.xul+xml')" />

<window id="tree-window"
    	title="Tree Window"
    	orient="vertical"
	xmlns:html="http://www.w3.org/1999/xhtml"
    	xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<script src="tree_js"/>

<box width="200" height="600">
  <tree open="true" container="true">
    <treechildren id="mainItems" flex="1">
      <tal:dummy replace="structure view/tree" />
    </treechildren>
  </tree>
</box>

</window>

=== Added File Zope3/lib/python/Zope/App/OFS/Content/Folder/Views/XUL/xmlrpclib.pt === (528/628 lines abridged)
//
//    Copyright (C) 2000, 2001, 2002  Virtual Cowboys info@virtualcowboys.nl
//		
//		Author: Ruben Daniels <ruben@virtualcowboys.nl>
//		Version: 0.91
//		Date: 29-08-2001
//		Site: www.vcdn.org/Public/XMLRPC/
//
//    This program is free software; you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation; either version 2 of the License, or
//    (at your option) any later version.
//
//    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


Object.prototype.toXMLRPC = function(){
  var wo = this.valueOf();
	
  if(wo.toXMLRPC == this.toXMLRPC){
     retstr = "<struct>";
    
    for(prop in this){
      if(typeof wo[prop] != "function"){
        retstr += "<member><name>" + prop + "</name><value>" + XMLRPC.getXML(wo[prop]) + "</value></member>";
      }
    }
    retstr += "</struct>";
    
    return retstr;
  }
  else{
    return wo.toXMLRPC();
  }
}

String.prototype.toXMLRPC = function(){
  //<![CDATA[***your text here***]]>
  return "<string><![CDATA[" + this.replace(/\]\]/g, "] ]") + "]]></string>";//.replace(/</g, "&lt;").replace(/&/g, "&amp;")
}

Number.prototype.toXMLRPC = function(){
  if(this == parseInt(this)){

[-=- -=- -=- 528 lines omitted -=- -=- -=-]

  },
  
  processResult : function(http){
    if(self.DEBUG) alert(http.responseText);
    if(http.status == 200){
      //getIncoming message
       dom = http.responseXML;

       if(dom){
         var rpcErr, main;

         //Check for XMLRPC Errors
         rpcErr = dom.getElementsByTagName("fault");
         if(rpcErr.length > 0){
           rpcErr = this.toObject(rpcErr[0].firstChild);
           this.handleError(new Error(rpcErr.faultCode, rpcErr.faultString));
           return false
         }

         //handle method result
         main = dom.getElementsByTagName("param");
          if(main.length == 0) this.handleError(new Error("Malformed XMLRPC Message"));
        data = this.toObject(this.getNode(main[0], [0]));

        //handle receiving
        if(this.onreceive) this.onreceive(data);
        return data;
       }
       else{
          this.handleError(new Error("Malformed XMLRPC Message"));
      }
    }
    else{
      this.handleError(new Error("HTTP Exception: (" + http.status + ") " + http.statusText + "\n\n" + http.responseText));
    }
  }
}

//Smell something
ver = navigator.appVersion;
app = navigator.appName;
isNS = Boolean(navigator.productSub)
//moz_can_do_http = (parseInt(navigator.productSub) >= 20010308)

isIE = (ver.indexOf("MSIE 5") != -1 || ver.indexOf("MSIE 6") != -1) ? 1 : 0;
isIE55 = (ver.indexOf("MSIE 5.5") != -1) ? 1 : 0;

isOTHER = (!isNS && !isIE) ? 1 : 0;

if(isOTHER) alert("Sorry your browser doesn't support the features of vcXMLRPC");


=== Added File Zope3/lib/python/Zope/App/OFS/Content/Folder/Views/XUL/xul.zcml ===
<zopeConfigure
   xmlns='http://namespaces.zope.org/zope'
   xmlns:security='http://namespaces.zope.org/security'
   xmlns:browser='http://namespaces.zope.org/browser'
>

  <!-- Loaded Folder View Directives -->

  <browser:view name="main_xul"
    for="Zope.App.OFS.IContainer.IReadContainer."
    factory="Zope.App.OFS.Content.Folder.Views.XUL.Main." />

  <security:protectClass 
    name="Zope.App.OFS.Content.Folder.Views.XUL.Main."
    permission_id="Zope.ManageContent" names="index, menu" />

  <browser:view name="tree"
    for="Zope.App.OFS.IContainer.IReadContainer."
    factory="Zope.App.OFS.Content.Folder.Views.XUL.Tree." />

  <security:protectClass 
    name="Zope.App.OFS.Content.Folder.Views.XUL.Tree."
    permission_id="Zope.ManageContent" names="getRDFTree" />

  <browser:view name="limit_xul"
    for="Zope.App.OFS.IContainerLimit."
    factory="Zope.App.OFS.Content.Folder.Views.XUL.SetLimit."/>

  <security:protectClass 
    name="Zope.App.OFS.Content.Folder.Views.XUL.SetLimit."
    permission_id="Zope.ManageContent" names="index, action, action_js" />

  <browser:view name="XULLimitFieldView"
    for="Zope.App.OFS.IContainerLimit."
    factory="Zope.App.OFS.Content.Folder.LoadedFolderFields.LimitField. Zope.App.Formulator.Widgets.XUL.TextWidget." />

</zopeConfigure>