Hi Sergiu,
Why is the feature done as template (just wondering)?
IMO the share this page feature should be an extension of the platform, not part of the
platform.
Thanks
-Vincent
On Nov 12, 2010, at 2:14 AM, sdumitriu (SVN) wrote:
Author: sdumitriu
Date: 2010-11-12 02:14:03 +0100 (Fri, 12 Nov 2010)
New Revision: 32739
Added:
platform/web/trunk/standard/src/main/webapp/templates/share.vm
platform/web/trunk/standard/src/main/webapp/templates/shareinline.vm
Log:
XE-750: Ability to send a link to a page by email
Done (templates)
Added: platform/web/trunk/standard/src/main/webapp/templates/share.vm
===================================================================
--- platform/web/trunk/standard/src/main/webapp/templates/share.vm
(rev 0)
+++ platform/web/trunk/standard/src/main/webapp/templates/share.vm 2010-11-12 01:14:03
UTC (rev 32739)
@@ -0,0 +1,6 @@
+###
+### Share page by email
+###
+###
+<div
id="document-title"><h1>$msg.get('core.viewers.share.title',
[$escapetool.xml($doc.displayTitle), $doc.getURL()])</h1></div>
+#template("shareinline.vm")
\ No newline at end of file
Property changes on: platform/web/trunk/standard/src/main/webapp/templates/share.vm
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: platform/web/trunk/standard/src/main/webapp/templates/shareinline.vm
===================================================================
--- platform/web/trunk/standard/src/main/webapp/templates/shareinline.vm
(rev 0)
+++ platform/web/trunk/standard/src/main/webapp/templates/shareinline.vm 2010-11-12
01:14:03 UTC (rev 32739)
@@ -0,0 +1,96 @@
+#template('xwikivars.vm')
+#if ($isGuest)
+## $response.setStatus(401)
+ #error ($msg.get('core.viewers.share.error.mustLogin'))
+#elseif ("$!{request.send}" != '')
+ #set ($message = "$!{request.message.trim()}")
+ #set ($sender = $xwiki.getUserName($context.user, false))
+ #set ($display = "$!{request.includeDocument}")
+## #if ("$!{xwiki.getXWikiPreference('admin_email')}" != '')
+## #set ($sender = "$sender
<$!{xwiki.getXWikiPreference('admin_email')}>")
+## #else
+ #set ($sender = "$sender <noreply(a)$!{request.localName}>")
+## #end
+
+ #set ($recipients = [])
+ #set ($errors = {})
+ #set ($successes = [])
+
+ #foreach ($recipientValue in $request.getParameterValues('target'))
+ #foreach ($recipient in $recipientValue.split(','))
+ #set ($recipient = $recipient.trim())
+ #if ($recipient != '')
+ #if ($recipient.indexOf('@') > 0)
+ #if ($recipient.indexOf('<') > 0)
+ #set ($recipientName = $recipient.substring(0,
$recipient.indexOf('<')).trim())
+ #else
+ #set ($recipientName = $recipient.substring(0,
$recipient.indexOf('(a)')).trim())
+ #end
+ #set ($fullRecipientName = $recipientName)
+ #else ## No @
+ #set ($recipientName =
$xwiki.getDocument($recipient).getObject('XWiki.XWikiUsers').getProperty('first_name').value)
+ #set ($fullRecipientName = $xwiki.getUserName($recipient, false))
+ #set ($recipient =
$xwiki.getDocument($recipient).getObject('XWiki.XWikiUsers').getProperty('email').value)
+ #end ## @
+ #if (!$recipients.contains($recipient) && "$!recipient" !=
'')
+ #set ($discard = $recipients.add($recipient))
+ #set ($result = $xwiki.mailsender.sendMessageFromTemplate($sender, $recipient,
${util.null}, ${util.null}, $context.language, 'XWiki.SharePage',
$context.vcontext))
+ #if ($result != 0)
+ #set ($discard = $errors.put($fullRecipientName,
$msg.get('core.viewers.share.error.serverError')))
+ #else
+ #set ($discard = $successes.add($fullRecipientName))
+ #end
+ #elseif ("$!recipient" == '')
+ #set($discard = $errors.put($fullRecipientName,
$msg.get('core.viewers.share.error.unknownEmail')))
+ #end ## Non empty/handled recipient
+ #end ## Non empty recipient
+ #end ## Foreach recipient
+ #end ## Foreach parameter value
+ #if ($successes.size() > 0)
+ #info($msg.get('core.viewers.share.send.success',
[$successes.toString().replaceAll('^\[', '').replaceAll('\]$',
'')]))
+ #end
+ #if ($errors.size() > 0)
+ #foreach ($recipient in $errors.keySet())
+ #error($msg.get('core.viewers.share.send.error', [${recipient},
${errors.get($recipient)}]))
+ #end
+ #end
+ <a href='$doc.getURL()'
class='share-backlink'>$msg.get('core.viewers.share.send.back',
["<em>${doc.displayTitle}</em>"])</a>
+#else ## Form not sent, display the UI
+$xwiki.jsx.use('XWiki.SharePage')
+<form class="xform" action="$doc.getURL('view',
'viewer=share')" method="post">
+ <div class="hidden">
+ <input type="hidden" name="form_token"
value="$services.csrf.token" />
+ <input type="hidden" name="send" value="1" />
+ </div>
+ <dl>
+ <dt>
+ <label
for="target">$msg.get('core.viewers.share.target')</label>
+ <span
class="xHint">$msg.get('core.viewers.share.target.hint')</span>
+ </dt>
+ <dd><input type="text" name="target"
id="target" value="" class="suggestUsers"/></dd>
+ #set ($ownEmail =
"$!{xwiki.getDocument($context.user).getObject('XWiki.XWikiUsers').getProperty('email').value}")
+ #if ($ownEmail != '')
+ <dd><label for="includeSender"><input
type="checkbox" id="includeSender" name="target"
value="${xwiki.getUserName($context.user, false)}
$escapetool.xml("<${ownEmail}>")" />
$msg.get('core.viewers.share.target.ccMe')</label></dd>
+ #end
+
<dt><label>$msg.get('core.viewers.share.includeMethod')</label></dt>
+ <dd><label><input type="radio"
name="includeDocument" value="link" checked="checked"/>
$msg.get('core.viewers.share.includeMethod.link')</label></dd>
+ <dd><label><input type="radio"
name="includeDocument" value="inline"/>
$msg.get('core.viewers.share.includeMethod.inline')</label></dd>
+ ## <dd><label><input type="radio"
name="includeDocument" value="attachment"/>
$msg.get('core.viewers.share.includeMethod.attachment')</label></dd>
+ ## <dd><label><input type="checkbox"
name="includeComments"/>
$msg.get('core.viewers.share.includeComments')</label></dd>
+
+ #set ($message = "<textarea name='message' rows='3'
cols='80'>${msg.get('core.viewers.share.defaultMessage')}</textarea>")
+ #set ($fullMessage =
$xwiki.getDocument('XWiki.SharePage').getObject('XWiki.Mail',
'language', $context.language, true).getProperty('html').value)
+ #set ($fullMessage = $fullMessage.replace('${recipientName}',
$msg.get('core.viewers.share.recipientPlaceholder')))
+ #set ($fullMessage =
$fullMessage.replaceAll('<pre[^>]*+>[^<]*+</pre>', $message))
+ #set ($fullMessage = $xwiki.parseContent($fullMessage))
+
+ <dt><label
for="message">$msg.get('core.viewers.share.messagePreviewLabel')</label></dt>
+ <dd class='mail-preview'>$fullMessage</dd>
+
+ </dl>
+ <div class="buttons">
+ <span class="buttonwrapper"><input type="submit"
class="button" value="$msg.get('core.viewers.share.submit')"
/></span>
+ <span class="buttonwrapper"><a class="secondary button"
href="$doc.getURL()">$msg.get('core.viewers.share.cancel')</a></span>
+ </div>
+</form>
+#end
\ No newline at end of file
Property changes on:
platform/web/trunk/standard/src/main/webapp/templates/shareinline.vm
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native