| 1 | <?xml version="1.0" encoding="UTF-8"?>
|
|---|
| 2 | <dictionary>
|
|---|
| 3 | <item key="custom"/>
|
|---|
| 4 | <item key="data"><![CDATA[# Import a standard function, and get the HTML request and response objects.
|
|---|
| 5 | from Products.PythonScripts.standard import html_quote
|
|---|
| 6 | request = container.REQUEST
|
|---|
| 7 | RESPONSE = request.RESPONSE
|
|---|
| 8 |
|
|---|
| 9 | print context.manage_page_header(context,request)
|
|---|
| 10 | print context.manage_tabs(context,request)
|
|---|
| 11 | print context.f_headline(context,headline='<big><img src="%sbtn_custom.gif" align="absmiddle" border="0"/> Edit Portal Content-Objects</big>'%context.MISC_ZMS)
|
|---|
| 12 | print '<form method="post" enctype="multipart/form-data">'
|
|---|
| 13 | print '<input type="hidden" name="form_id" value="manage_editPortalContentObjects"/>'
|
|---|
| 14 | print '<input type="hidden" name="lang" value="%s"/>'%request['lang']
|
|---|
| 15 | print context.zmi_form_section_begin(context,request)
|
|---|
| 16 |
|
|---|
| 17 | print """
|
|---|
| 18 | <script>
|
|---|
| 19 | $(function() {
|
|---|
| 20 | $("div.metaobj")
|
|---|
| 21 | .addClass("ui-helper-clickable")
|
|---|
| 22 | .click(function() {
|
|---|
| 23 | var newClazz = "";
|
|---|
| 24 | if ($(this).hasClass("inactive")) {
|
|---|
| 25 | $(this).removeClass("inactive");
|
|---|
| 26 | newClass = "active";
|
|---|
| 27 | }
|
|---|
| 28 | else if ($(this).hasClass("active")) {
|
|---|
| 29 | $(this).removeClass("active");
|
|---|
| 30 | newClass = "acquired";
|
|---|
| 31 | }
|
|---|
| 32 | else if ($(this).hasClass("acquired")) {
|
|---|
| 33 | $(this).removeClass("acquired");
|
|---|
| 34 | newClass = "inactive";
|
|---|
| 35 | }
|
|---|
| 36 | $("input",this).val("");
|
|---|
| 37 | $(this).removeClass("modified").addClass(newClass);
|
|---|
| 38 | if (!($(this).hasClass("initial"+newClass))) {
|
|---|
| 39 | $("input",this).val(newClass);
|
|---|
| 40 | $(this).addClass("modified");
|
|---|
| 41 | }
|
|---|
| 42 | });
|
|---|
| 43 | });
|
|---|
| 44 | </script>
|
|---|
| 45 | <style>
|
|---|
| 46 | div.metaobj {
|
|---|
| 47 | margin:2px;
|
|---|
| 48 | width:16px;
|
|---|
| 49 | height:16px;
|
|---|
| 50 | background-color:#AAA;
|
|---|
| 51 | border-right:1px solid #666;
|
|---|
| 52 | border-bottom:1px solid #666;
|
|---|
| 53 | }
|
|---|
| 54 | div.metaobj img {
|
|---|
| 55 | width:16px;
|
|---|
| 56 | height:16px;
|
|---|
| 57 | border:none;
|
|---|
| 58 | }
|
|---|
| 59 | div.metaobj.active {
|
|---|
| 60 | background:url(/misc_/zms/mi.gif) #CCC top left no-repeat;
|
|---|
| 61 | }
|
|---|
| 62 | div.metaobj.inactive {
|
|---|
| 63 | background:url(/misc_/zms/pl.gif) #CCC top left no-repeat;
|
|---|
| 64 | }
|
|---|
| 65 | div.metaobj.acquired {
|
|---|
| 66 | background:url(/misc_/zms/mi.gif) #BEDAFD top left no-repeat;
|
|---|
| 67 | }
|
|---|
| 68 | div.metaobj.acquired img {
|
|---|
| 69 | background:url(/misc_/zms/ico_is_acquired.gif) top right no-repeat;
|
|---|
| 70 | }
|
|---|
| 71 | div.metaobj.warning img {
|
|---|
| 72 | background:url(/misc_/zms/decorator_warning.gif) top right no-repeat;
|
|---|
| 73 | }
|
|---|
| 74 | div.metaobj.modified {
|
|---|
| 75 | background-color:#FDBEDA;
|
|---|
| 76 | border-right:1px solid #F00;
|
|---|
| 77 | border-bottom:1px solid #F00;
|
|---|
| 78 | }
|
|---|
| 79 | td.vert {
|
|---|
| 80 | height:150px!important;
|
|---|
| 81 | vertical-align: bottom;
|
|---|
| 82 | padding-bottom: 10px;
|
|---|
| 83 | overflow: hidden;
|
|---|
| 84 | }
|
|---|
| 85 | div.vert {
|
|---|
| 86 | -moz-transform:rotate(-90deg);
|
|---|
| 87 | writing-mode: tb-rl;
|
|---|
| 88 | white-space: nowrap;
|
|---|
| 89 | width:20px!important;
|
|---|
| 90 | }
|
|---|
| 91 | </style>
|
|---|
| 92 | """
|
|---|
| 93 |
|
|---|
| 94 | if request.get('btn') == context.getZMILangStr('BTN_SAVE'):
|
|---|
| 95 | request.set('__get_metaobjs__',True)
|
|---|
| 96 | print '<div id="system_msg" class="ui-state-highlight ui-corner-all" style="margin:1em">'
|
|---|
| 97 | print '<span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>'
|
|---|
| 98 | for client in context.getPortalClients():
|
|---|
| 99 | homeid = client.getHome().id
|
|---|
| 100 | for reqkey in request.keys():
|
|---|
| 101 | if reqkey.startswith(homeid+"-") and len(request[reqkey]) > 0:
|
|---|
| 102 | metaObjId = reqkey[len(homeid+"-"):]
|
|---|
| 103 | action = request[reqkey]
|
|---|
| 104 | print '<strong>%s</strong>'%homeid, metaObjId, '<em>(%s)</em>'%action
|
|---|
| 105 | if action == 'inactive':
|
|---|
| 106 | client.metaobj_manager.delMetaobj(metaObjId)
|
|---|
| 107 | print '<code>Done</code>'
|
|---|
| 108 | elif action == 'active':
|
|---|
| 109 | xml = context.metaobj_manager.exportMetaobjXml([id])
|
|---|
| 110 | client.metaobj_manager.importMetaobjXml(xml=xml)
|
|---|
| 111 | print '<code>Done</code>'
|
|---|
| 112 | elif action == 'acquired':
|
|---|
| 113 | client.metaobj_manager.acquireMetaobj(metaObjId)
|
|---|
| 114 | print '<code>Done</code>'
|
|---|
| 115 | print '<br/>'
|
|---|
| 116 | print '</div>'
|
|---|
| 117 |
|
|---|
| 118 | if request.get('btn') == context.getZMILangStr('BTN_CANCEL'):
|
|---|
| 119 | RESPONSE.redirect('%s/manage_main'%context.absolute_url())
|
|---|
| 120 |
|
|---|
| 121 | print '<table border="1" cellspacing="0" cellpadding="0">'
|
|---|
| 122 | print '<tr class="zmiNeutralColorMedium0">'
|
|---|
| 123 | print '<td>'+context.getHome().id+'</td>'
|
|---|
| 124 | metaObjTuplesTemp = []
|
|---|
| 125 | for metaObjId in context.getMetaobjIds():
|
|---|
| 126 | metaObj = context.getMetaobj(metaObjId)
|
|---|
| 127 | metaObjTuplesTemp.append((metaObj['name'],metaObj['id']))
|
|---|
| 128 | metaObjTuplesTemp.sort()
|
|---|
| 129 | metaObjTuples = []
|
|---|
| 130 | for metaObjTuple in metaObjTuplesTemp:
|
|---|
| 131 | metaObjId = metaObjTuple[1]
|
|---|
| 132 | metaObjName = metaObjTuple[0]
|
|---|
| 133 | metaObj = context.getMetaobj(metaObjId)
|
|---|
| 134 | if metaObj['type'] == 'ZMSPackage':
|
|---|
| 135 | metaObjTuples.append((metaObjName,metaObj))
|
|---|
| 136 | for metaObjTuple2 in metaObjTuplesTemp:
|
|---|
| 137 | metaObjId2 = metaObjTuple2[1]
|
|---|
| 138 | metaObjName2 = metaObjTuple2[0]
|
|---|
| 139 | metaObj2 = context.getMetaobj(metaObjId2)
|
|---|
| 140 | if metaObj2['package'] == metaObjId:
|
|---|
| 141 | metaObjTuples.append((metaObjName2,metaObj2))
|
|---|
| 142 | elif metaObj['package'] == '':
|
|---|
| 143 | metaObjTuples.append((metaObjName,metaObj))
|
|---|
| 144 | for metaObjTuple in metaObjTuples:
|
|---|
| 145 | metaObj = metaObjTuple[1]
|
|---|
| 146 | metaObjId = metaObj['id']
|
|---|
| 147 | metaObjName = metaObjTuple[0]
|
|---|
| 148 | print '<td class="vert"><div class="vert">'
|
|---|
| 149 | if metaObj['package'] != '':
|
|---|
| 150 | print '<img src="%s" width="8" height="8" align="absmiddle" border="0"/>'%(context.spacer_gif)
|
|---|
| 151 | print '<img src="%s" align="absmiddle" border="0"/>'%(context.display_icon(request,metaObjId))
|
|---|
| 152 | if metaObj['type'] == 'ZMSPackage':
|
|---|
| 153 | print '<strong>%s</strong> (%s)'%(metaObj['name'],metaObj.get('revision','0.0.0'))
|
|---|
| 154 | else:
|
|---|
| 155 | print '%s (%s)'%(metaObj['name'],metaObj.get('revision','0.0.0'))
|
|---|
| 156 | print '</div></td>'
|
|---|
| 157 | print '</tr>'
|
|---|
| 158 | for client in context.getPortalClients():
|
|---|
| 159 | clientMetaObjIds = client.getMetaobjIds()
|
|---|
| 160 | print '<tr class="zmiNeutralColorLight0">'
|
|---|
| 161 | print '<td class="form-small"><a href="'+client.absolute_url()+'/metaobj_manager/manage_main" target="_blank" class="zmi">'+client.getHome().id+'</a></td>'
|
|---|
| 162 | for metaObjTuple in metaObjTuples:
|
|---|
| 163 | metaObj = metaObjTuple[1]
|
|---|
| 164 | metaObjId = metaObj['id']
|
|---|
| 165 | metaObjName = metaObjTuple[0]
|
|---|
| 166 | clientMetaObj = client.getMetaobj(metaObjId)
|
|---|
| 167 | clazz = ['metaobj']
|
|---|
| 168 | title = ''
|
|---|
| 169 | if metaObjId in clientMetaObjIds:
|
|---|
| 170 | if client.getMetaobj(metaObjId)['acquired']:
|
|---|
| 171 | title = 'acquired'
|
|---|
| 172 | clazz.append('acquired')
|
|---|
| 173 | else:
|
|---|
| 174 | title = 'active'
|
|---|
| 175 | if metaObj.get('revision','0.0.0') != clientMetaObj.get('revision','0.0.0'):
|
|---|
| 176 | title += ' (%s)'%(clientMetaObj.get('revision','0.0.0'))
|
|---|
| 177 | clazz.append('warning')
|
|---|
| 178 | else:
|
|---|
| 179 | metaObjAttrIds = map(lambda x: x['id'], metaObj['attrs'])
|
|---|
| 180 | clientMetaObjAttrIds = map(lambda x: x['id'], clientMetaObj['attrs'])
|
|---|
| 181 | if metaObjAttrIds != clientMetaObjAttrIds:
|
|---|
| 182 | title += ' (-%s, +%s)'%(str(filter(lambda x: x not in clientMetaObjAttrIds,metaObjAttrIds)),str(filter(lambda x: x not in metaObjAttrIds,clientMetaObjAttrIds)))
|
|---|
| 183 | clazz.append('warning')
|
|---|
| 184 | clazz.append('active')
|
|---|
| 185 | else:
|
|---|
| 186 | title = 'inactive'
|
|---|
| 187 | clazz.append('inactive')
|
|---|
| 188 | clazz.append('initial'+clazz[-1])
|
|---|
| 189 | print '<td align="center"><div class="'+' '.join(clazz)+'" title="'+title+'">'
|
|---|
| 190 | print '<input type="hidden" name="'+client.getHome().id+'-'+metaObjId+'" value=""/>'
|
|---|
| 191 | print '<img src="/misc_/zms/spacer.gif" alt=""/></div></td>'
|
|---|
| 192 | print '</tr>'
|
|---|
| 193 | print '</table>'
|
|---|
| 194 |
|
|---|
| 195 | print context.zmi_form_section_end(context,request)
|
|---|
| 196 |
|
|---|
| 197 | print '<div class="zmi-form-section ui-widget-content ui-corner-all">'
|
|---|
| 198 | print '<input class="ui-button ui-state-active ui-corner-all" name="btn" type="submit" value="'+context.getZMILangStr('BTN_SAVE')+'">'
|
|---|
| 199 | print '<input class="ui-button ui-state-default ui-corner-all" name="btn" type="submit" value="'+context.getZMILangStr('BTN_RESET')+'">'
|
|---|
| 200 | print '<input class="ui-button ui-state-default ui-corner-all" name="btn" type="submit" value="'+context.getZMILangStr('BTN_CANCEL')+'">'
|
|---|
| 201 | print '</div>'
|
|---|
| 202 |
|
|---|
| 203 | print '</form>'
|
|---|
| 204 | print context.manage_page_footer(context,request)
|
|---|
| 205 |
|
|---|
| 206 | return printed
|
|---|
| 207 | ]]>
|
|---|
| 208 | </item>
|
|---|
| 209 | <item key="description"/>
|
|---|
| 210 | <item key="exec" type="int">0</item>
|
|---|
| 211 | <item key="id"><![CDATA[manage_editPortalContentObjects]]></item>
|
|---|
| 212 | <item key="meta_type"><![CDATA[Script (Python)]]></item>
|
|---|
| 213 | <item key="meta_types" type="list">
|
|---|
| 214 | <list>
|
|---|
| 215 | <item><![CDATA[ZMS]]></item>
|
|---|
| 216 | </list>
|
|---|
| 217 | </item>
|
|---|
| 218 | <item key="name"><![CDATA[Edit Portal Content-Objects...]]></item>
|
|---|
| 219 | <item key="roles" type="list">
|
|---|
| 220 | <list>
|
|---|
| 221 | <item><![CDATA[ZMSAdministrator]]></item>
|
|---|
| 222 | </list>
|
|---|
| 223 | </item>
|
|---|
| 224 | </dictionary> |
|---|