Back to index

moin  1.9.0~rc2
Functions
MoinMoin.action.fckdialog Namespace Reference

Functions

def macro_dialog
 Macro dialog.
def macro_list
def get_macro_help
def page_list
 Link dialog.
def link_dialog
def attachment_dialog
def image_dialog
 Image dialog.
def execute
 Main.

Function Documentation

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 

Definition at line 363 of file fckdialog.py.

00363 
00364 def attachment_dialog(request):
00365     """ Attachment dialog for GUI editor. """
00366     """ Features: This dialog can... """
00367     """ - list attachments in a drop down list """
00368     """ - list attachments also for a different page than the current one """
00369     """ - create new attachment """
00370     _ = request.getText
00371     url_prefix_static = request.cfg.url_prefix_static
00372 
00373     # wiki url
00374     action = request.script_root + "/"
00375 
00376     # The following code lines implement the feature "list attachments for a different page".
00377     # Meaning of the variables:
00378     # - requestedPagename : Name of the page where attachments shall be listed from.
00379     # - attachmentsPagename : Name of the page where the attachments where retrieved from.
00380     # - destinationPagename : Name of the page where attachment will be placed on.
00381 
00382     requestedPagename = wikiutil.escape(request.values.get("requestedPagename", ""), quote=True)
00383     destinationPagename = wikiutil.escape(request.values.get("destinationPagename", request.page.page_name), quote=True)
00384 
00385     attachmentsPagename = requestedPagename or request.page.page_name
00386     attachments = _get_files(request, attachmentsPagename)
00387     attachments.sort()
00388     attachmentList = '''
00389         <select id="sctAttachments" size="10" style="width:100%%;visibility:hidden;" onchange="OnAttachmentListChange();">
00390         %s
00391         </select>
00392 ''' % "\n".join(['<option value="%s">%s</option>' % (wikiutil.escape(attachment, quote=True), wikiutil.escape(attachment, quote=True))
00393                  for attachment in attachments])
00394 
00395     # Translation of dialog texts.
00396     langAttachmentLocation = _("Attachment location")
00397     langPagename = _("Page name")
00398     langAttachmentname = _("Attachment name")
00399     langListAttachmentsButton = _("Refresh attachment list")
00400     langAttachmentList = _("List of attachments")
00401 
00402     if len(attachmentsPagename) > 50:
00403         shortenedPagename = "%s ... %s" % (attachmentsPagename[0:25], attachmentsPagename[-25:])
00404     else:
00405         shortenedPagename = attachmentsPagename
00406     langAvailableAttachments = "%s: %s" % (_("Available attachments for page"), shortenedPagename)
00407 
00408     request.write('''
00409 <!--
00410  * FCKeditor - The text editor for internet
00411  * Copyright (C) 2003-2004 Frederico Caldeira Knabben
00412  *
00413  * Licensed under the terms of the GNU Lesser General Public License:
00414  *   http://www.opensource.org/licenses/lgpl-license.php
00415  *
00416  * For further information visit:
00417  *   http://www.fckeditor.net/
00418  *
00419  * File Name: fck_attachment.html
00420  *  Attachment dialog window.
00421  *
00422  * Version:  2.0 FC (Preview)
00423  * Modified: 2005-02-18 23:55:22
00424  *
00425  * File Authors:
00426  *   Frederico Caldeira Knabben (fredck@fckeditor.net)
00427 -->
00428 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
00429 <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
00430 <meta name="robots" content="index,nofollow">
00431 <html>
00432  <head>
00433   <title>Attachment Properties</title>
00434   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
00435   <meta name="robots" content="noindex,nofollow" />
00436   <script src="%(url_prefix_static)s/applets/FCKeditor/editor/dialog/common/fck_dialog_common.js" type="text/javascript"></script>
00437   <script src="%(url_prefix_static)s/applets/moinFCKplugins/moinattachment/fck_attachment.js" type="text/javascript"></script>
00438   <script src="%(url_prefix_static)s/applets/moinFCKplugins/moinurllib.js" type="text/javascript"></script>
00439  </head>
00440  <body scroll="no" style="OVERFLOW: hidden">
00441     <form id="DlgAttachmentForm" name="DlgAttachmentForm" action=%(action)s method="GET">
00442     <input type="hidden" name="action" value="fckdialog">
00443     <input type="hidden" name="dialog" value="attachment">
00444     <input type="hidden" id="requestedPagename" name="requestedPagename" value="%(requestedPagename)s">
00445     <input type="hidden" id="attachmentsPagename" name="attachmentsPagename" value="%(attachmentsPagename)s">
00446     <input type="hidden" id="destinationPagename" name="destinationPagename" value="%(destinationPagename)s">
00447 
00448     <div id="divInfo" style="valign=top;">
00449     <div id="divLinkTypeAttachment">
00450     <fieldset>
00451     <legend>%(langAttachmentLocation)s</legend>
00452     <table cellSpacing="0" cellPadding="0" width="100%%" border="0">
00453         <tr>
00454             <td valign="bottom" style="width:90%%" style="padding-bottom:10px">
00455                 <span>%(langPagename)s</span><br>
00456             </td>
00457         </tr>
00458         <tr>
00459             <td valign="bottom" style="width:100%%" style="padding-bottom:10px;padding-right:10px;">
00460                 <input id="txtPagename" type="text" onkeyup="OnPagenameChange();" onchange="OnPagenameChange();" style="width:98%%">
00461             </td>
00462         </tr>
00463         <tr>
00464             <td valign="bottom" style="width:90%%" style="padding-bottom:10px;">
00465                 <span>%(langAttachmentname)s</span><br>
00466             </td>
00467         </tr>
00468         <tr valign="bottom">
00469             <td valign="bottom" style="width:100%%" style="padding-bottom:10px;padding-right:10px;">
00470                 <input id="txtAttachmentname" type="text" onkeyup="OnAttachmentnameChange();" onchange="OnPagenameChange();" style="width:98%%"><br>
00471             </td>
00472         </tr>
00473     </table>
00474     </fieldset>
00475     <fieldset>
00476     <legend>%(langAvailableAttachments)s</legend>
00477     <table cellSpacing="0" cellPadding="0" width="100%%" border="0">
00478         <tr>
00479             <td valign="bottom" style="width:100%%" style="padding-bottom:10px">
00480                 <input id="btnListAttachments" type="submit" value="%(langListAttachmentsButton)s">
00481             </td>
00482         </tr>
00483         <tr>
00484             <td valign="top" style="padding-top:10px">
00485                 <label for="sctAttachments">%(langAttachmentList)s</label><br>
00486                 %(attachmentList)s
00487             </td>
00488         </tr>
00489     </table>
00490     </fieldset>
00491    </div>
00492   </div>
00493    </form>
00494  </body>
00495 </html>
00496 ''' % locals())
00497 

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.action.fckdialog.execute (   pagename,
  request 
)

Main.

Definition at line 564 of file fckdialog.py.

00564 
00565 def execute(pagename, request):
00566     dialog = request.values.get("dialog", "")
00567 
00568     if dialog == "macro":
00569         macro_dialog(request)
00570     elif dialog == "macrolist":
00571         macro_list(request)
00572     elif dialog == "pagelist":
00573         page_list(request)
00574     elif dialog == "link":
00575         link_dialog(request)
00576     elif dialog == "attachment":
00577         attachment_dialog(request)
00578     elif dialog == 'image':
00579         image_dialog(request)
00580     else:
00581         from MoinMoin.Page import Page
00582         request.theme.add_msg("Dialog unknown!", "error")
00583         Page(request, pagename).send_page()
00584 

Here is the call graph for this function:

Read help texts from SystemPage('HelpOnMacros')

Definition at line 147 of file fckdialog.py.

00147 
00148 def get_macro_help(request):
00149     """ Read help texts from SystemPage('HelpOnMacros')"""
00150     helppage = wikiutil.getLocalizedPage(request, "HelpOnMacros")
00151     content = helppage.get_raw_body()
00152     macro_re = re.compile(
00153         r"\|\|(<.*?>)?\{\{\{" +
00154         r"<<(?P<prototype>(?P<macro>\w*).*)>>" +
00155         r"\}\}\}\s*\|\|" +
00156         r"[^|]*\|\|[^|]*\|\|<[^>]*>" +
00157         r"\s*(?P<help>.*?)\s*\|\|\s*(?P<example>.*?)\s*(<<[^>]*>>)*\s*\|\|$", re.U|re.M)
00158     help = {}
00159     for match in macro_re.finditer(content):
00160         help[match.group('macro')] = match
00161     return help

Here is the caller graph for this function:

Image dialog.

Definition at line 502 of file fckdialog.py.

00502 
00503 def image_dialog(request):
00504     url_prefix_static = request.cfg.url_prefix_static
00505     request.write('''
00506 <!--
00507  * FCKeditor - The text editor for internet
00508  * Copyright (C) 2003-2004 Frederico Caldeira Knabben
00509  *
00510  * Licensed under the terms of the GNU Lesser General Public License:
00511  *   http://www.opensource.org/licenses/lgpl-license.php
00512  *
00513  * For further information visit:
00514  *   http://www.fckeditor.net/
00515  *
00516  * File Authors:
00517  *   Frederico Caldeira Knabben (fredck@fckeditor.net)
00518  *   Florian Festi
00519 -->
00520 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
00521 <html>
00522  <head>
00523   <title>Link Properties</title>
00524   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
00525   <meta name="robots" content="noindex,nofollow" />
00526   <script src="%(url_prefix_static)s/applets/FCKeditor/editor/dialog/common/fck_dialog_common.js" type="text/javascript"></script>
00527   <script src="%(url_prefix_static)s/applets/moinFCKplugins/moinimage/fck_image.js" type="text/javascript"></script>
00528   <script src="%(url_prefix_static)s/applets/moinFCKplugins/moinurllib.js" type="text/javascript"></script>
00529  </head>
00530  <body scroll="no" style="OVERFLOW: hidden">
00531     <table cellspacing="0" cellpadding="0" width="100%%" border="0">
00532      <tr>
00533       <td nowrap="nowrap">
00534        <span fckLang="DlgLnkProto">Protocol</span><br />
00535        <select id="cmbLinkProtocol" onchange="OnProtocolChange();">
00536         <option value="attachment:" selected="selected">attachment:</option>
00537         <option value="http://">http://</option>
00538         <option value="https://">https://</option>
00539         <!-- crashes often: <option value="drawing:">drawing:</option> -->
00540         <option value="" fckLang="DlgLnkProtoOther">&lt;other&gt;</option>
00541        </select>
00542       </td>
00543       <td nowrap="nowrap">&nbsp;</td>
00544       <td nowrap="nowrap" width="100%%">
00545        <span fckLang="DlgLnkURL">URL or File Name (attachment:)</span><br />
00546        <input id="txtUrl" style="WIDTH: 100%%" type="text" onkeyup="OnUrlChange();" onchange="OnUrlChange();" />
00547       </td>
00548      </tr>
00549      <tr>
00550       <td colspan=2>
00551        <div id="divChkLink">
00552         <input id="chkLink" type="checkbox"> Link to
00553        </div>
00554       </td>
00555     </table>
00556  </body>
00557 </html>
00558 ''' % locals())
00559 

Here is the caller graph for this function:

Definition at line 203 of file fckdialog.py.

00203 
00204 def link_dialog(request):
00205     # list of wiki pages
00206     name = request.values.get("pagename", "")
00207     if name:
00208         from MoinMoin import search
00209         # XXX error handling!
00210         searchresult = search.searchPages(request, 't:"%s"' % name)
00211 
00212         pages = [p.page_name for p in searchresult.hits]
00213         pages.sort()
00214         pages[0:0] = [name]
00215         page_list = '''
00216          <tr>
00217           <td colspan=2>
00218            <select id="sctPagename" size="1" onchange="OnChangePagename(this.value);">
00219            %s
00220            </select>
00221           <td>
00222          </tr>
00223 ''' % "\n".join(['<option value="%s">%s</option>' % (page, page)
00224                  for page in pages])
00225     else:
00226         page_list = ""
00227 
00228     # list of interwiki names
00229     interwiki_list = wikiutil.load_wikimap(request)
00230     interwiki = interwiki_list.keys()
00231     interwiki.sort()
00232     iwpreferred = request.cfg.interwiki_preferred[:]
00233     if not iwpreferred or iwpreferred and iwpreferred[-1] is not None:
00234         resultlist = iwpreferred
00235         for iw in interwiki:
00236             if not iw in iwpreferred:
00237                 resultlist.append(iw)
00238     else:
00239         resultlist = iwpreferred[:-1]
00240     interwiki = "\n".join(
00241         ['<option value="%s">%s</option>' % (key, key) for key in resultlist])
00242 
00243     # wiki url
00244     url_prefix_static = request.cfg.url_prefix_static
00245     scriptname = request.script_root + '/'
00246     action = scriptname
00247     basepage = request.page.page_name
00248     request.write(u'''
00249 <!--
00250  * FCKeditor - The text editor for internet
00251  * Copyright (C) 2003-2004 Frederico Caldeira Knabben
00252  *
00253  * Licensed under the terms of the GNU Lesser General Public License:
00254  *   http://www.opensource.org/licenses/lgpl-license.php
00255  *
00256  * For further information visit:
00257  *   http://www.fckeditor.net/
00258  *
00259  * File Name: fck_link.html
00260  *  Link dialog window.
00261  *
00262  * Version:  2.0 FC (Preview)
00263  * Modified: 2005-02-18 23:55:22
00264  *
00265  * File Authors:
00266  *   Frederico Caldeira Knabben (fredck@fckeditor.net)
00267 -->
00268 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
00269 <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
00270 <meta name="robots" content="index,nofollow">
00271 <html>
00272  <head>
00273   <title>Link Properties</title>
00274   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
00275   <meta name="robots" content="noindex,nofollow" />
00276   <script src="%(url_prefix_static)s/applets/FCKeditor/editor/dialog/common/fck_dialog_common.js" type="text/javascript"></script>
00277   <script src="%(url_prefix_static)s/applets/moinFCKplugins/moinlink/fck_link.js" type="text/javascript"></script>
00278   <script src="%(url_prefix_static)s/applets/moinFCKplugins/moinurllib.js" type="text/javascript"></script>
00279  </head>
00280  <body scroll="no" style="OVERFLOW: hidden">
00281   <div id="divInfo" style="DISPLAY: none">
00282    <span fckLang="DlgLnkType">Link Type</span><br />
00283    <select id="cmbLinkType" onchange="SetLinkType(this.value);">
00284     <option value="wiki" selected="selected">WikiPage</option>
00285     <option value="interwiki">Interwiki</option>
00286     <option value="url" fckLang="DlgLnkTypeURL">URL</option>
00287    </select>
00288    <br />
00289    <br />
00290    <div id="divLinkTypeWiki">
00291     <table height="100%%" cellSpacing="0" cellPadding="0" width="100%%" border="0">
00292      <tr>
00293       <td>
00294        <form action=%(action)s method="GET">
00295        <input type="hidden" name="action" value="fckdialog">
00296        <input type="hidden" name="dialog" value="link">
00297        <input type="hidden" id="basepage" name="basepage" value="%(basepage)s">
00298        <table cellSpacing="0" cellPadding="0" align="center" border="0">
00299         <tr>
00300          <td>
00301           <span fckLang="PageDlgName">Page Name</span><br>
00302           <input id="txtPagename" name="pagename" size="30" value="%(name)s">
00303          </td>
00304          <td valign="bottom">
00305            <input id=btnSearchpage type="submit" value="Search">
00306          </td>
00307         </tr>
00308         %(page_list)s
00309        </table>
00310        </form>
00311       </td>
00312      </tr>
00313     </table>
00314    </div>
00315    <div id="divLinkTypeInterwiki">
00316     <table height="100%%" cellSpacing="0" cellPadding="0" width="100%%" border="0">
00317      <tr>
00318       <td>
00319        <table cellSpacing="0" cellPadding="0" align="center" border="0">
00320         <tr>
00321          <td>
00322           <span fckLang="WikiDlgName">Wiki:PageName</span><br>
00323           <select id="sctInterwiki" size="1">
00324           %(interwiki)s
00325           </select>:
00326           <input id="txtInterwikipagename"></input>
00327          </td>
00328         </tr>
00329        </table>
00330       </td>
00331      </tr>
00332     </table>
00333    </div>
00334    <div id="divLinkTypeUrl">
00335     <table cellspacing="0" cellpadding="0" width="100%%" border="0">
00336      <tr>
00337       <td nowrap="nowrap">
00338        <span fckLang="DlgLnkProto">Protocol</span><br />
00339        <select id="cmbLinkProtocol">
00340         <option value="http://" selected="selected">http://</option>
00341         <option value="https://">https://</option>
00342         <option value="ftp://">ftp://</option>
00343         <option value="file://">file://</option>
00344         <option value="news://">news://</option>
00345         <option value="mailto:">mailto:</option>
00346         <option value="" fckLang="DlgLnkProtoOther">&lt;other&gt;</option>
00347        </select>
00348       </td>
00349       <td nowrap="nowrap">&nbsp;</td>
00350       <td nowrap="nowrap" width="100%%">
00351        <span fckLang="DlgLnkURL">URL</span><br />
00352        <input id="txtUrl" style="WIDTH: 100%%" type="text" onkeyup="OnUrlChange();" onchange="OnUrlChange();" />
00353       </td>
00354      </tr>
00355     </table>
00356     <br />
00357    </div>
00358   </div>
00359  </body>
00360 </html>
00361 ''' % locals())
00362 

Here is the caller graph for this function:

Macro dialog.

Definition at line 18 of file fckdialog.py.

00018 
00019 def macro_dialog(request):
00020     help = get_macro_help(request)
00021     request.write(
00022         '''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
00023 <html>
00024  <head>
00025   <title>Insert Macro</title>
00026   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
00027   <meta content="noindex,nofollow" name="robots">
00028   <script src="%s/applets/FCKeditor/editor/dialog/common/fck_dialog_common.js" type="text/javascript"></script>
00029   <script language="javascript">
00030 
00031 var oEditor = window.parent.InnerDialogLoaded() ;
00032 var FCKLang = oEditor.FCKLang ;
00033 var FCKMacros = oEditor.FCKMacros ;
00034 
00035 window.onload = function ()
00036 {
00037  // First of all, translate the dialog box texts
00038  oEditor.FCKLanguageManager.TranslatePage( document ) ;
00039 
00040  OnChange( "BR" );
00041 
00042  // Show the "Ok" button.
00043  window.parent.SetOkButton( true ) ;
00044 }
00045 
00046 function Ok()
00047 {
00048  if ( document.getElementById('txtName').value.length == 0 )
00049  {
00050   alert( FCKLang.MacroErrNoName ) ;
00051   return false ;
00052  }
00053 
00054  FCKMacros.Add( txtName.value ) ;
00055  return true ;
00056 }
00057 
00058 function OnChange( sMacro )
00059 {
00060   // sMacro = GetE("txtName").value;
00061   oHelp = GetE("help");
00062   for (var i=0; i<oHelp.childNodes.length; i++)
00063   {
00064     var oDiv = oHelp.childNodes[i];
00065     if (oDiv.nodeType==1)
00066     {
00067       // oDiv.style.display = (GetAttribute(oDiv, "id", "")==sMacro) ? '' : 'none';
00068       if (GetAttribute(oDiv, "id", "") == sMacro)
00069       {
00070           oDiv.style.display = '' ;
00071           // alert("enabled div id " + sMacro) ;
00072       }
00073       else
00074       {
00075           oDiv.style.display = 'none' ;
00076       }
00077     }
00078   }
00079 }
00080 
00081   </script>
00082  </head>
00083  <body scroll="no" style="OVERFLOW: hidden">
00084   <table height="100%%" cellSpacing="0" cellPadding="0" width="100%%" border="0">
00085    <tr>
00086     <td>
00087      <table cellSpacing="0" cellPadding="0" align="center" border="0">
00088       <tr>
00089        <td valign="top">
00090        <span fckLang="MacroDlgName">Macro Name</span><br>
00091        <select id="txtName" size="10" onchange="OnChange(this.value);">
00092 ''' % request.cfg.url_prefix_static)
00093 
00094     macros = []
00095     for macro in macro_list(request):
00096         if macro == "BR":
00097             selected = ' selected="selected"'
00098         else:
00099             selected = ''
00100         if macro in help:
00101             macros.append('<option value="%s"%s>%s</option>' %
00102                           (help[macro].group('prototype'), selected, macro))
00103         else:
00104             macros.append('<option value="%s"%s>%s</option>' %
00105                           (macro, selected, macro))
00106 
00107     request.write('\n'.join(macros))
00108     request.write('''
00109        </select>
00110      </td>
00111      <td id="help">''')
00112 
00113     helptexts = []
00114     for macro in macro_list(request):
00115         if macro in help:
00116             match = help[macro]
00117             prototype = match.group('prototype')
00118             helptext = match.group('help')
00119         else:
00120             prototype = macro
00121             helptext = ""
00122         helptexts.append(
00123             '''<div id="%s" style="DISPLAY: none">
00124                <b>&lt;&lt;%s&gt;&gt;</b>
00125                <br/>
00126                <textarea style="color:#000000" cols="37" rows="10" disabled="disabled">%s</textarea>
00127                </div>'''
00128             % (prototype, prototype, helptext))
00129 
00130     request.write(''.join(helptexts))
00131     request.write('''
00132      </td>
00133     </tr>
00134    </table>
00135   </td>
00136  </tr>
00137 </table>
00138 </body>
00139 </html>
00140 ''')

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 141 of file fckdialog.py.

00141 
00142 def macro_list(request):
00143     from MoinMoin import macro
00144     macros = macro.getNames(request.cfg)
00145     macros.sort()
00146     return macros

Here is the caller graph for this function:

Link dialog.

Definition at line 166 of file fckdialog.py.

00166 
00167 def page_list(request):
00168     from MoinMoin import search
00169     name = request.values.get("pagename", "")
00170     if name:
00171         searchresult = search.searchPages(request, 't:"%s"' % name)
00172         pages = [p.page_name for p in searchresult.hits]
00173     else:
00174         pages = [name]
00175     request.write(
00176         '''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
00177 <html>
00178  <head>
00179   <title>Insert Page Link</title>
00180   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
00181   <meta content="noindex,nofollow" name="robots">
00182  </head>
00183  <body scroll="no" style="OVERFLOW: hidden">
00184   <table height="100%%" cellSpacing="0" cellPadding="0" width="100%%" border="0">
00185    <tr>
00186     <td>
00187      <table cellSpacing="0" cellPadding="0" align="center" border="0">
00188       <tr>
00189        <td>
00190        <span fckLang="PageDlgName">Page Name</span><br>
00191        <select id="txtName" size="1">
00192        %s
00193        </select>
00194      </td>
00195     </tr>
00196    </table>
00197   </td>
00198  </tr>
00199 </table>
00200 </body>
00201 </html>
00202 ''' % "".join(["<option>%s</option>\n" % p for p in pages]))

Here is the caller graph for this function: