/usr/share/pyshared/MoinMoin/action/fckdialog.py is in python-moinmoin 1.9.3-1ubuntu2.3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | # -*- coding: iso-8859-1 -*-
"""
MoinMoin - feed some FCKeditor dialogues
@copyright: 2005-2006 Bastian Blank, Florian Festi, Thomas Waldmann
@license: GNU GPL, see COPYING for details.
"""
from MoinMoin import config, wikiutil
from MoinMoin.action.AttachFile import _get_files
from MoinMoin.Page import Page
import re
##############################################################################
### Macro dialog
##############################################################################
def macro_dialog(request):
help = get_macro_help(request)
request.write(
'''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Insert Macro</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta content="noindex,nofollow" name="robots">
<script src="%s/applets/FCKeditor/editor/dialog/common/fck_dialog_common.js" type="text/javascript"></script>
<script language="javascript">
var oEditor = window.parent.InnerDialogLoaded() ;
var FCKLang = oEditor.FCKLang ;
var FCKMacros = oEditor.FCKMacros ;
window.onload = function ()
{
// First of all, translate the dialog box texts
oEditor.FCKLanguageManager.TranslatePage( document ) ;
OnChange( "BR" );
// Show the "Ok" button.
window.parent.SetOkButton( true ) ;
}
function Ok()
{
if ( document.getElementById('txtName').value.length == 0 )
{
alert( FCKLang.MacroErrNoName ) ;
return false ;
}
FCKMacros.Add( txtName.value ) ;
return true ;
}
function OnChange( sMacro )
{
// sMacro = GetE("txtName").value;
oHelp = GetE("help");
for (var i=0; i<oHelp.childNodes.length; i++)
{
var oDiv = oHelp.childNodes[i];
if (oDiv.nodeType==1)
{
// oDiv.style.display = (GetAttribute(oDiv, "id", "")==sMacro) ? '' : 'none';
if (GetAttribute(oDiv, "id", "") == sMacro)
{
oDiv.style.display = '' ;
// alert("enabled div id " + sMacro) ;
}
else
{
oDiv.style.display = 'none' ;
}
}
}
}
</script>
</head>
<body scroll="no" style="OVERFLOW: hidden">
<table height="100%%" cellSpacing="0" cellPadding="0" width="100%%" border="0">
<tr>
<td>
<table cellSpacing="0" cellPadding="0" align="center" border="0">
<tr>
<td valign="top">
<span fckLang="MacroDlgName">Macro Name</span><br>
<select id="txtName" size="10" onchange="OnChange(this.value);">
''' % request.cfg.url_prefix_static)
macros = []
for macro in macro_list(request):
if macro == "BR":
selected = ' selected="selected"'
else:
selected = ''
if macro in help:
macros.append('<option value="%s"%s>%s</option>' %
(help[macro].group('prototype'), selected, macro))
else:
macros.append('<option value="%s"%s>%s</option>' %
(macro, selected, macro))
request.write('\n'.join(macros))
request.write('''
</select>
</td>
<td id="help">''')
helptexts = []
for macro in macro_list(request):
if macro in help:
match = help[macro]
prototype = match.group('prototype')
helptext = match.group('help')
else:
prototype = macro
helptext = ""
helptexts.append(
'''<div id="%s" style="DISPLAY: none">
<b><<%s>></b>
<br/>
<textarea style="color:#000000" cols="37" rows="10" disabled="disabled">%s</textarea>
</div>'''
% (prototype, prototype, helptext))
request.write(''.join(helptexts))
request.write('''
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
''')
def macro_list(request):
from MoinMoin import macro
macros = macro.getNames(request.cfg)
macros.sort()
return macros
def get_macro_help(request):
""" Read help texts from SystemPage('HelpOnMacros')"""
helppage = wikiutil.getLocalizedPage(request, "HelpOnMacros")
content = helppage.get_raw_body()
macro_re = re.compile(
r"\|\|(<.*?>)?\{\{\{" +
r"<<(?P<prototype>(?P<macro>\w*).*)>>" +
r"\}\}\}\s*\|\|" +
r"[^|]*\|\|[^|]*\|\|<[^>]*>" +
r"\s*(?P<help>.*?)\s*\|\|\s*(?P<example>.*?)\s*(<<[^>]*>>)*\s*\|\|$", re.U|re.M)
help = {}
for match in macro_re.finditer(content):
help[match.group('macro')] = match
return help
##############################################################################
### Link dialog
##############################################################################
def page_list(request):
from MoinMoin import search
name = request.values.get("pagename", "")
if name:
searchresult = search.searchPages(request, 't:"%s"' % name)
pages = [p.page_name for p in searchresult.hits]
else:
pages = [name]
request.write(
'''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Insert Page Link</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta content="noindex,nofollow" name="robots">
</head>
<body scroll="no" style="OVERFLOW: hidden">
<table height="100%%" cellSpacing="0" cellPadding="0" width="100%%" border="0">
<tr>
<td>
<table cellSpacing="0" cellPadding="0" align="center" border="0">
<tr>
<td>
<span fckLang="PageDlgName">Page name</span><br>
<select id="txtName" size="1">
%s
</select>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
''' % "".join(["<option>%s</option>\n" % wikiutil.escape(p) for p in pages]))
def link_dialog(request):
# list of wiki pages
name = request.values.get("pagename", "")
if name:
from MoinMoin import search
# XXX error handling!
searchresult = search.searchPages(request, 't:"%s"' % name)
pages = [p.page_name for p in searchresult.hits]
pages.sort()
pages[0:0] = [name]
page_list = '''
<tr>
<td colspan=2>
<select id="sctPagename" size="1" onchange="OnChangePagename(this.value);">
%s
</select>
<td>
</tr>
''' % "\n".join(['<option value="%s">%s</option>' % (wikiutil.escape(page), wikiutil.escape(page))
for page in pages])
else:
page_list = ""
# list of interwiki names
interwiki_list = wikiutil.load_wikimap(request)
interwiki = interwiki_list.keys()
interwiki.sort()
iwpreferred = request.cfg.interwiki_preferred[:]
if not iwpreferred or iwpreferred and iwpreferred[-1] is not None:
resultlist = iwpreferred
for iw in interwiki:
if not iw in iwpreferred:
resultlist.append(iw)
else:
resultlist = iwpreferred[:-1]
interwiki = "\n".join(
['<option value="%s">%s</option>' % (wikiutil.escape(key), wikiutil.escape(key))
for key in resultlist])
# wiki url
url_prefix_static = request.cfg.url_prefix_static
scriptname = request.script_root + '/'
action = scriptname
basepage = wikiutil.escape(request.page.page_name)
request.write(u'''
<!--
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2004 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* For further information visit:
* http://www.fckeditor.net/
*
* File Name: fck_link.html
* Link dialog window.
*
* Version: 2.0 FC (Preview)
* Modified: 2005-02-18 23:55:22
*
* File Authors:
* Frederico Caldeira Knabben (fredck@fckeditor.net)
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="robots" content="index,nofollow">
<html>
<head>
<title>Link Properties</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex,nofollow" />
<script src="%(url_prefix_static)s/applets/FCKeditor/editor/dialog/common/fck_dialog_common.js" type="text/javascript"></script>
<script src="%(url_prefix_static)s/applets/moinFCKplugins/moinlink/fck_link.js" type="text/javascript"></script>
<script src="%(url_prefix_static)s/applets/moinFCKplugins/moinurllib.js" type="text/javascript"></script>
</head>
<body scroll="no" style="OVERFLOW: hidden">
<div id="divInfo" style="DISPLAY: none">
<span fckLang="DlgLnkType">Link Type</span><br />
<select id="cmbLinkType" onchange="SetLinkType(this.value);">
<option value="wiki" selected="selected">WikiPage</option>
<option value="interwiki">Interwiki</option>
<option value="url" fckLang="DlgLnkTypeURL">URL</option>
</select>
<br />
<br />
<div id="divLinkTypeWiki">
<table height="100%%" cellSpacing="0" cellPadding="0" width="100%%" border="0">
<tr>
<td>
<form action=%(action)s method="GET">
<input type="hidden" name="action" value="fckdialog">
<input type="hidden" name="dialog" value="link">
<input type="hidden" id="basepage" name="basepage" value="%(basepage)s">
<table cellSpacing="0" cellPadding="0" align="center" border="0">
<tr>
<td>
<span fckLang="PageDlgName">Page Name</span><br>
<input id="txtPagename" name="pagename" size="30" value="%(name)s">
</td>
<td valign="bottom">
<input id=btnSearchpage type="submit" value="Search">
</td>
</tr>
%(page_list)s
</table>
</form>
</td>
</tr>
</table>
</div>
<div id="divLinkTypeInterwiki">
<table height="100%%" cellSpacing="0" cellPadding="0" width="100%%" border="0">
<tr>
<td>
<table cellSpacing="0" cellPadding="0" align="center" border="0">
<tr>
<td>
<span fckLang="WikiDlgName">Wiki:PageName</span><br>
<select id="sctInterwiki" size="1">
%(interwiki)s
</select>:
<input id="txtInterwikipagename"></input>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div id="divLinkTypeUrl">
<table cellspacing="0" cellpadding="0" width="100%%" border="0">
<tr>
<td nowrap="nowrap">
<span fckLang="DlgLnkProto">Protocol</span><br />
<select id="cmbLinkProtocol">
<option value="http://" selected="selected">http://</option>
<option value="https://">https://</option>
<option value="ftp://">ftp://</option>
<option value="file://">file://</option>
<option value="news://">news://</option>
<option value="mailto:">mailto:</option>
<option value="" fckLang="DlgLnkProtoOther"><other></option>
</select>
</td>
<td nowrap="nowrap"> </td>
<td nowrap="nowrap" width="100%%">
<span fckLang="DlgLnkURL">URL</span><br />
<input id="txtUrl" style="WIDTH: 100%%" type="text" onkeyup="OnUrlChange();" onchange="OnUrlChange();" />
</td>
</tr>
</table>
<br />
</div>
</div>
</body>
</html>
''' % locals())
def attachment_dialog(request):
""" Attachment dialog for GUI editor. """
""" Features: This dialog can... """
""" - list attachments in a drop down list """
""" - list attachments also for a different page than the current one """
""" - create new attachment """
_ = request.getText
url_prefix_static = request.cfg.url_prefix_static
# wiki url
action = request.script_root + "/"
# The following code lines implement the feature "list attachments for a different page".
# Meaning of the variables:
# - requestedPagename : Name of the page where attachments shall be listed from.
# - attachmentsPagename : Name of the page where the attachments where retrieved from.
# - destinationPagename : Name of the page where attachment will be placed on.
requestedPagename = wikiutil.escape(request.values.get("requestedPagename", ""), quote=True)
destinationPagename = wikiutil.escape(request.values.get("destinationPagename", request.page.page_name), quote=True)
attachmentsPagename = requestedPagename or wikiutil.escape(request.page.page_name)
attachments = _get_files(request, attachmentsPagename)
attachments.sort()
attachmentList = '''
<select id="sctAttachments" size="10" style="width:100%%;visibility:hidden;" onchange="OnAttachmentListChange();">
%s
</select>
''' % "\n".join(['<option value="%s">%s</option>' % (wikiutil.escape(attachment, quote=True), wikiutil.escape(attachment, quote=True))
for attachment in attachments])
# Translation of dialog texts.
langAttachmentLocation = _("Attachment location")
langPagename = _("Page name")
langAttachmentname = _("Attachment name")
langListAttachmentsButton = _("Refresh attachment list")
langAttachmentList = _("List of attachments")
if len(attachmentsPagename) > 50:
shortenedPagename = "%s ... %s" % (attachmentsPagename[0:25], attachmentsPagename[-25:])
else:
shortenedPagename = attachmentsPagename
langAvailableAttachments = "%s: %s" % (_("Available attachments for page"), shortenedPagename)
request.write('''
<!--
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2004 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* For further information visit:
* http://www.fckeditor.net/
*
* File Name: fck_attachment.html
* Attachment dialog window.
*
* Version: 2.0 FC (Preview)
* Modified: 2005-02-18 23:55:22
*
* File Authors:
* Frederico Caldeira Knabben (fredck@fckeditor.net)
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="robots" content="index,nofollow">
<html>
<head>
<title>Attachment Properties</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex,nofollow" />
<script src="%(url_prefix_static)s/applets/FCKeditor/editor/dialog/common/fck_dialog_common.js" type="text/javascript"></script>
<script src="%(url_prefix_static)s/applets/moinFCKplugins/moinattachment/fck_attachment.js" type="text/javascript"></script>
<script src="%(url_prefix_static)s/applets/moinFCKplugins/moinurllib.js" type="text/javascript"></script>
</head>
<body scroll="no" style="OVERFLOW: hidden">
<form id="DlgAttachmentForm" name="DlgAttachmentForm" action=%(action)s method="GET">
<input type="hidden" name="action" value="fckdialog">
<input type="hidden" name="dialog" value="attachment">
<input type="hidden" id="requestedPagename" name="requestedPagename" value="%(requestedPagename)s">
<input type="hidden" id="attachmentsPagename" name="attachmentsPagename" value="%(attachmentsPagename)s">
<input type="hidden" id="destinationPagename" name="destinationPagename" value="%(destinationPagename)s">
<div id="divInfo" style="valign=top;">
<div id="divLinkTypeAttachment">
<fieldset>
<legend>%(langAttachmentLocation)s</legend>
<table cellSpacing="0" cellPadding="0" width="100%%" border="0">
<tr>
<td valign="bottom" style="width:90%%" style="padding-bottom:10px">
<span>%(langPagename)s</span><br>
</td>
</tr>
<tr>
<td valign="bottom" style="width:100%%" style="padding-bottom:10px;padding-right:10px;">
<input id="txtPagename" type="text" onkeyup="OnPagenameChange();" onchange="OnPagenameChange();" style="width:98%%">
</td>
</tr>
<tr>
<td valign="bottom" style="width:90%%" style="padding-bottom:10px;">
<span>%(langAttachmentname)s</span><br>
</td>
</tr>
<tr valign="bottom">
<td valign="bottom" style="width:100%%" style="padding-bottom:10px;padding-right:10px;">
<input id="txtAttachmentname" type="text" onkeyup="OnAttachmentnameChange();" onchange="OnPagenameChange();" style="width:98%%"><br>
</td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>%(langAvailableAttachments)s</legend>
<table cellSpacing="0" cellPadding="0" width="100%%" border="0">
<tr>
<td valign="bottom" style="width:100%%" style="padding-bottom:10px">
<input id="btnListAttachments" type="submit" value="%(langListAttachmentsButton)s">
</td>
</tr>
<tr>
<td valign="top" style="padding-top:10px">
<label for="sctAttachments">%(langAttachmentList)s</label><br>
%(attachmentList)s
</td>
</tr>
</table>
</fieldset>
</div>
</div>
</form>
</body>
</html>
''' % locals())
##############################################################################
### Image dialog
##############################################################################
def image_dialog(request):
url_prefix_static = request.cfg.url_prefix_static
request.write('''
<!--
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2004 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* For further information visit:
* http://www.fckeditor.net/
*
* File Authors:
* Frederico Caldeira Knabben (fredck@fckeditor.net)
* Florian Festi
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Link Properties</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex,nofollow" />
<script src="%(url_prefix_static)s/applets/FCKeditor/editor/dialog/common/fck_dialog_common.js" type="text/javascript"></script>
<script src="%(url_prefix_static)s/applets/moinFCKplugins/moinimage/fck_image.js" type="text/javascript"></script>
<script src="%(url_prefix_static)s/applets/moinFCKplugins/moinurllib.js" type="text/javascript"></script>
</head>
<body scroll="no" style="OVERFLOW: hidden">
<table cellspacing="0" cellpadding="0" width="100%%" border="0">
<tr>
<td nowrap="nowrap">
<span fckLang="DlgLnkProto">Protocol</span><br />
<select id="cmbLinkProtocol" onchange="OnProtocolChange();">
<option value="attachment:" selected="selected">attachment:</option>
<option value="http://">http://</option>
<option value="https://">https://</option>
<!-- crashes often: <option value="drawing:">drawing:</option> -->
<option value="" fckLang="DlgLnkProtoOther"><other></option>
</select>
</td>
<td nowrap="nowrap"> </td>
<td nowrap="nowrap" width="100%%">
<span fckLang="DlgLnkURL">URL or File Name (attachment:)</span><br />
<input id="txtUrl" style="WIDTH: 100%%" type="text" onkeyup="OnUrlChange();" onchange="OnUrlChange();" />
</td>
</tr>
<tr>
<td colspan=2>
<div id="divChkLink">
<input id="chkLink" type="checkbox"> Link to
</div>
</td>
</table>
</body>
</html>
''' % locals())
#############################################################################
### Main
#############################################################################
def execute(pagename, request):
dialog = request.values.get("dialog", "")
if dialog == "macro":
macro_dialog(request)
elif dialog == "macrolist":
macro_list(request)
elif dialog == "pagelist":
page_list(request)
elif dialog == "link":
link_dialog(request)
elif dialog == "attachment":
attachment_dialog(request)
elif dialog == 'image':
image_dialog(request)
else:
from MoinMoin.Page import Page
request.theme.add_msg("Dialog unknown!", "error")
Page(request, pagename).send_page()
|