~ubuntu-branches/ubuntu/oneiric/moin/oneiric-security

« back to all changes in this revision

Viewing changes to MoinMoin/action/fckdialog.py

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2010-03-30 12:55:34 UTC
  • mfrom: (0.1.17 sid)
  • Revision ID: james.westby@ubuntu.com-20100330125534-4c2ufc1rok24447l
Tags: 1.9.2-2ubuntu1
* Merge from Debian testing (LP: #521834). Based on work by Stefan Ebner.
  Remaining changes:
 - Remove python-xml from Suggests field, the package isn't anymore in
   sys.path.
 - Demote fckeditor from Recommends to Suggests; the code was previously
   embedded in moin, but it was also disabled, so there's no reason for us
   to pull this in by default currently. Note: This isn't necessary anymore
   but needs a MIR for fckeditor, so postpone dropping this change until
   lucid+1
* debian/rules:
  - Replace hardcoded python2.5 with python* and hardcore python2.6 for ln
* debian/control.in: drop versioned depends on cdbs

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
"""
8
8
 
9
9
from MoinMoin import config, wikiutil
 
10
from MoinMoin.action.AttachFile import _get_files
 
11
from MoinMoin.Page import Page
10
12
import re
11
13
 
12
14
##############################################################################
15
17
 
16
18
def macro_dialog(request):
17
19
    help = get_macro_help(request)
18
 
    request.emit_http_headers()
19
20
    request.write(
20
21
        '''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
21
22
<html>
164
165
 
165
166
def page_list(request):
166
167
    from MoinMoin import search
167
 
    name = request.form.get("pagename", [""])[0]
 
168
    name = request.values.get("pagename", "")
168
169
    if name:
169
170
        searchresult = search.searchPages(request, 't:"%s"' % name)
170
171
        pages = [p.page_name for p in searchresult.hits]
171
172
    else:
172
173
        pages = [name]
173
 
    request.emit_http_headers()
174
174
    request.write(
175
175
        '''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
176
176
<html>
186
186
     <table cellSpacing="0" cellPadding="0" align="center" border="0">
187
187
      <tr>
188
188
       <td>
189
 
       <span fckLang="PageDlgName">Page Name</span><br>
 
189
       <span fckLang="PageDlgName">Page name</span><br>
190
190
       <select id="txtName" size="1">
191
191
       %s
192
192
       </select>
201
201
''' % "".join(["<option>%s</option>\n" % p for p in pages]))
202
202
 
203
203
def link_dialog(request):
204
 
    request.emit_http_headers()
205
204
    # list of wiki pages
206
 
    name = request.form.get("pagename", [""])[0]
 
205
    name = request.values.get("pagename", "")
207
206
    if name:
208
207
        from MoinMoin import search
209
208
        # XXX error handling!
242
241
 
243
242
    # wiki url
244
243
    url_prefix_static = request.cfg.url_prefix_static
245
 
    scriptname = request.getScriptname()
246
 
    if not scriptname or scriptname[-1] != "/":
247
 
        scriptname += "/"
 
244
    scriptname = request.script_root + '/'
248
245
    action = scriptname
249
246
    basepage = request.page.page_name
250
247
    request.write(u'''
362
359
</html>
363
360
''' % locals())
364
361
 
365
 
##############################################################################
366
 
### Attachment dialog
367
 
##############################################################################
368
362
 
369
363
def attachment_dialog(request):
370
 
    request.emit_http_headers()
371
 
    # list of wiki pages
372
 
    name = request.form.get("pagename", [""])[0]
373
 
    if name:
374
 
        from MoinMoin import search
375
 
        # XXX error handling!
376
 
        searchresult = search.searchPages(request, 't:"%s"' % name)
377
 
 
378
 
        pages = [p.page_name for p in searchresult.hits]
379
 
        pages.sort()
380
 
        pages[0:0] = [name]
381
 
        page_list = '''
382
 
         <tr>
383
 
          <td colspan=2>
384
 
           <select id="sctPagename" size="1" onchange="OnChangePagename(this.value);">
385
 
           %s
386
 
           </select>
387
 
          <td>
388
 
         </tr>
389
 
''' % "\n".join(['<option value="%s">%s</option>' % (page, page)
390
 
                 for page in pages])
 
364
    """ Attachment dialog for GUI editor. """
 
365
    """ Features: This dialog can... """
 
366
    """ - list attachments in a drop down list """
 
367
    """ - list attachments also for a different page than the current one """
 
368
    """ - create new attachment """
 
369
    _ = request.getText
 
370
    url_prefix_static = request.cfg.url_prefix_static
 
371
 
 
372
    # wiki url
 
373
    action = request.script_root + "/"
 
374
 
 
375
    # The following code lines implement the feature "list attachments for a different page".
 
376
    # Meaning of the variables:
 
377
    # - requestedPagename : Name of the page where attachments shall be listed from.
 
378
    # - attachmentsPagename : Name of the page where the attachments where retrieved from.
 
379
    # - destinationPagename : Name of the page where attachment will be placed on.
 
380
 
 
381
    requestedPagename = wikiutil.escape(request.values.get("requestedPagename", ""), quote=True)
 
382
    destinationPagename = wikiutil.escape(request.values.get("destinationPagename", request.page.page_name), quote=True)
 
383
 
 
384
    attachmentsPagename = requestedPagename or request.page.page_name
 
385
    attachments = _get_files(request, attachmentsPagename)
 
386
    attachments.sort()
 
387
    attachmentList = '''
 
388
        <select id="sctAttachments" size="10" style="width:100%%;visibility:hidden;" onchange="OnAttachmentListChange();">
 
389
        %s
 
390
        </select>
 
391
''' % "\n".join(['<option value="%s">%s</option>' % (wikiutil.escape(attachment, quote=True), wikiutil.escape(attachment, quote=True))
 
392
                 for attachment in attachments])
 
393
 
 
394
    # Translation of dialog texts.
 
395
    langAttachmentLocation = _("Attachment location")
 
396
    langPagename = _("Page name")
 
397
    langAttachmentname = _("Attachment name")
 
398
    langListAttachmentsButton = _("Refresh attachment list")
 
399
    langAttachmentList = _("List of attachments")
 
400
 
 
401
    if len(attachmentsPagename) > 50:
 
402
        shortenedPagename = "%s ... %s" % (attachmentsPagename[0:25], attachmentsPagename[-25:])
391
403
    else:
392
 
        page_list = ""
 
404
        shortenedPagename = attachmentsPagename
 
405
    langAvailableAttachments = "%s: %s" % (_("Available attachments for page"), shortenedPagename)
393
406
 
394
 
    # wiki url
395
 
    url_prefix_static = request.cfg.url_prefix_static
396
 
    scriptname = request.getScriptname()
397
 
    if not scriptname or scriptname[-1] != "/":
398
 
        scriptname += "/"
399
 
    action = scriptname
400
407
    request.write('''
401
408
<!--
402
409
 * FCKeditor - The text editor for internet
430
437
  <script src="%(url_prefix_static)s/applets/moinFCKplugins/moinurllib.js" type="text/javascript"></script>
431
438
 </head>
432
439
 <body scroll="no" style="OVERFLOW: hidden">
433
 
  <div id="divInfo">
434
 
   <div id="divLinkTypeAttachment">
435
 
    <table height="100%%" cellSpacing="0" cellPadding="0" width="100%%" border="0">
436
 
     <tr>
437
 
      <td>
438
 
       <form action=%(action)s method="GET">
439
 
       <input type="hidden" name="action" value="fckdialog">
440
 
       <input type="hidden" name="dialog" value="attachment">
441
 
       <table cellSpacing="0" cellPadding="0" align="center" border="0">
442
 
        <tr>
443
 
         <td>
444
 
          <span fckLang="AttachmentDlgName">Attachment Name</span><br>
445
 
          <input id="txtAttachmentname" name="pagename" size="30" value="%(name)s">
446
 
         </td>
447
 
        </tr>
448
 
       </table>
449
 
       </form>
450
 
      </td>
451
 
     </tr>
452
 
    </table>
 
440
    <form id="DlgAttachmentForm" name="DlgAttachmentForm" action=%(action)s method="GET">
 
441
    <input type="hidden" name="action" value="fckdialog">
 
442
    <input type="hidden" name="dialog" value="attachment">
 
443
    <input type="hidden" id="requestedPagename" name="requestedPagename" value="%(requestedPagename)s">
 
444
    <input type="hidden" id="attachmentsPagename" name="attachmentsPagename" value="%(attachmentsPagename)s">
 
445
    <input type="hidden" id="destinationPagename" name="destinationPagename" value="%(destinationPagename)s">
 
446
 
 
447
    <div id="divInfo" style="valign=top;">
 
448
    <div id="divLinkTypeAttachment">
 
449
    <fieldset>
 
450
    <legend>%(langAttachmentLocation)s</legend>
 
451
    <table cellSpacing="0" cellPadding="0" width="100%%" border="0">
 
452
        <tr>
 
453
            <td valign="bottom" style="width:90%%" style="padding-bottom:10px">
 
454
                <span>%(langPagename)s</span><br>
 
455
            </td>
 
456
        </tr>
 
457
        <tr>
 
458
            <td valign="bottom" style="width:100%%" style="padding-bottom:10px;padding-right:10px;">
 
459
                <input id="txtPagename" type="text" onkeyup="OnPagenameChange();" onchange="OnPagenameChange();" style="width:98%%">
 
460
            </td>
 
461
        </tr>
 
462
        <tr>
 
463
            <td valign="bottom" style="width:90%%" style="padding-bottom:10px;">
 
464
                <span>%(langAttachmentname)s</span><br>
 
465
            </td>
 
466
        </tr>
 
467
        <tr valign="bottom">
 
468
            <td valign="bottom" style="width:100%%" style="padding-bottom:10px;padding-right:10px;">
 
469
                <input id="txtAttachmentname" type="text" onkeyup="OnAttachmentnameChange();" onchange="OnPagenameChange();" style="width:98%%"><br>
 
470
            </td>
 
471
        </tr>
 
472
    </table>
 
473
    </fieldset>
 
474
    <fieldset>
 
475
    <legend>%(langAvailableAttachments)s</legend>
 
476
    <table cellSpacing="0" cellPadding="0" width="100%%" border="0">
 
477
        <tr>
 
478
            <td valign="bottom" style="width:100%%" style="padding-bottom:10px">
 
479
                <input id="btnListAttachments" type="submit" value="%(langListAttachmentsButton)s">
 
480
            </td>
 
481
        </tr>
 
482
        <tr>
 
483
            <td valign="top" style="padding-top:10px">
 
484
                <label for="sctAttachments">%(langAttachmentList)s</label><br>
 
485
                %(attachmentList)s
 
486
            </td>
 
487
        </tr>
 
488
    </table>
 
489
    </fieldset>
453
490
   </div>
454
491
  </div>
 
492
   </form>
455
493
 </body>
456
494
</html>
457
495
''' % locals())
458
496
 
 
497
 
459
498
##############################################################################
460
499
### Image dialog
461
500
##############################################################################
462
501
 
463
502
def image_dialog(request):
464
 
    request.emit_http_headers()
465
503
    url_prefix_static = request.cfg.url_prefix_static
466
504
    request.write('''
467
505
<!--
524
562
#############################################################################
525
563
 
526
564
def execute(pagename, request):
527
 
    dialog = request.form.get("dialog", [""])[0]
 
565
    dialog = request.values.get("dialog", "")
528
566
 
529
567
    if dialog == "macro":
530
568
        macro_dialog(request)