Polls implemented

main
Inga 🏳‍🌈 15 years ago
parent 84f3f53725
commit e2e6ee4482
  1. 2
      Builder/IISMainHandler/build.txt
  2. 24
      Common/BBCodes/Poll.cs
  3. 2
      Common/Common.csproj
  4. 6
      Common/UBBParser.cs
  5. 2
      Common/actions/ChangeSet.cs
  6. 297
      Common/dataobjects/Poll.cs
  7. 14
      IISMainHandler/HandlersFactory.cs
  8. 4
      IISMainHandler/IISMainHandler.csproj
  9. 47
      IISMainHandler/handlers/request/CreatePollHandler.cs
  10. 39
      IISMainHandler/handlers/request/VoteHandler.cs
  11. 27
      IISMainHandler/handlers/response/CreatePollHandler.cs
  12. 32
      IISMainHandler/handlers/response/PollHandler.cs
  13. 192
      templates/Full/NewPoll.xslt
  14. 44
      templates/Full/Poll.xslt
  15. 167
      templates/Full/elems/PollInfo.xslt
  16. 5
      templates/Full/elems/TextEditor.xslt
  17. 35
      templates/Full/result/PollCreated.xslt
  18. 31
      templates/Full/result/VoteAccepted.xslt

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PJonDevelopment.BBCode;
namespace FLocal.Common.BBCodes {
class Poll : BBCode {
public Poll()
: base("poll") {
}
public override string Format(ITextFormatter formatter) {
var poll = dataobjects.Poll.LoadById(int.Parse(this.DefaultOrValue));
var name = poll.title;
if(this.Default != null) {
name = this.GetInnerHTML(formatter);
}
return "<a href=\"/Poll/" + poll.id.ToString() + "/\">" + name + "</a>";
}
}
}

@ -67,6 +67,7 @@
<Compile Include="BBCodes\Image.cs" />
<Compile Include="BBCodes\List.cs" />
<Compile Include="BBCodes\ListElem.cs" />
<Compile Include="BBCodes\Poll.cs" />
<Compile Include="BBCodes\Quote.cs" />
<Compile Include="BBCodes\S.cs" />
<Compile Include="BBCodes\Spoiler.cs" />
@ -85,6 +86,7 @@
<Compile Include="dataobjects\AnonymousUserSettings.cs" />
<Compile Include="dataobjects\PMConversation.cs" />
<Compile Include="dataobjects\PMMessage.cs" />
<Compile Include="dataobjects\Poll.cs" />
<Compile Include="dataobjects\Post.cs" />
<Compile Include="dataobjects\PostLayer.cs" />
<Compile Include="dataobjects\QuickLink.cs" />

@ -6,6 +6,7 @@ using System.Web;
using System.Text.RegularExpressions;
using PJonDevelopment.BBCode;
using System.IO;
using FLocal.Core;
namespace FLocal.Common {
public static class UBBParser {
@ -97,6 +98,7 @@ namespace FLocal.Common {
this.parser.ElementTypes.Add("image", typeof(BBCodes.Image), true);
this.parser.ElementTypes.Add("list", typeof(BBCodes.List), true);
this.parser.ElementTypes.Add("*", typeof(BBCodes.ListElem), false);
this.parser.ElementTypes.Add("poll", typeof(BBCodes.Poll), true);
this.parser.ElementTypes.Add("quote", typeof(BBCodes.Quote), true);this.parser.ElementTypes.Add("q", typeof(BBCodes.Quote), true);
this.parser.ElementTypes.Add("s", typeof(BBCodes.S), true);
this.parser.ElementTypes.Add("spoiler", typeof(BBCodes.Spoiler), true);this.parser.ElementTypes.Add("cut", typeof(BBCodes.Spoiler), true);
@ -109,7 +111,9 @@ namespace FLocal.Common {
}
public string Parse(string input) {
return this.parser.Parse(input).Format(this.formatter);
string result = this.parser.Parse(input).Format(this.formatter);
if(result.EndsWith("<br/>")) result = result.Substring(0, result.Length - 5);
return result;
}
}

@ -31,6 +31,8 @@ namespace FLocal.Common.actions {
dataobjects.PMMessage.TableSpec.TABLE,
dataobjects.Thread.ReadMarkerTableSpec.TABLE,
dataobjects.Board.ReadMarkerTableSpec.TABLE,
dataobjects.Poll.TableSpec.TABLE,
dataobjects.Poll.Vote.TableSpec.TABLE,
dataobjects.Session.TableSpec.TABLE,
}
);

@ -0,0 +1,297 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using FLocal.Core;
using FLocal.Core.DB;
using FLocal.Core.DB.conditions;
using FLocal.Common.actions;
namespace FLocal.Common.dataobjects {
public class Poll : SqlObject<Poll> {
private class PollOptionInfo {
public string name;
public int votes;
public List<int> voters;
public bool selected;
}
public class TableSpec : ISqlObjectTableSpec {
public const string TABLE = "Polls";
public const string FIELD_ID = "Id";
public const string FIELD_TITLE = "Title";
public const string FIELD_ISDETAILED = "IsDetailed";
public const string FIELD_ISMULTIOPTION = "IsMultiOption";
public const string FIELD_OPTIONS = "Options";
public const string FIELD_POSTERID = "PosterId";
public const string FIELD_POSTDATE = "PostDate";
public static readonly TableSpec instance = new TableSpec();
public string name { get { return TABLE; } }
public string idName { get { return FIELD_ID; } }
public void refreshSqlObject(int id) { Refresh(id); }
}
public class Vote : SqlObject<Vote> {
public class TableSpec : ISqlObjectTableSpec {
public const string TABLE = "Votes";
public const string FIELD_ID = "Id";
public const string FIELD_POLLID = "PollId";
public const string FIELD_USERID = "UserId";
public const string FIELD_VOTEINFO = "VoteInfo";
public static readonly TableSpec instance = new TableSpec();
public string name { get { return TABLE; }}
public string idName { get { return FIELD_ID; }}
public void refreshSqlObject(int id) { }
}
protected override ISqlObjectTableSpec table { get { return TableSpec.instance; } }
private int _userId;
public int userId {
get {
this.LoadIfNotLoaded();
return this._userId;
}
}
public User user {
get {
return User.LoadById(this.userId);
}
}
private HashSet<int> _options;
public HashSet<int> options {
get {
this.LoadIfNotLoaded();
return this._options;
}
}
protected override void doFromHash(Dictionary<string, string> data) {
this._userId = int.Parse(data[TableSpec.FIELD_USERID]);
this._options = new HashSet<int>(from elem in XElement.Parse(data[TableSpec.FIELD_VOTEINFO]).Descendants("vote") select int.Parse(elem.Attribute("optionId").Value));
}
}
protected override ISqlObjectTableSpec table { get { return TableSpec.instance; } }
private string _title;
public string title {
get {
this.LoadIfNotLoaded();
return this._title;
}
}
private bool _isDetailed;
public bool isDetailed {
get {
this.LoadIfNotLoaded();
return this._isDetailed;
}
}
private bool _isMultiOption;
public bool isMultiOption {
get {
this.LoadIfNotLoaded();
return this._isMultiOption;
}
}
private Dictionary<int, string> _options;
public Dictionary<int, string> options {
get {
this.LoadIfNotLoaded();
return this._options;
}
}
private int _posterId;
public int posterId {
get {
this.LoadIfNotLoaded();
return this._posterId;
}
}
public User poster {
get {
return User.LoadById(this._posterId);
}
}
private DateTime _postDate;
public DateTime postDate {
get {
this.LoadIfNotLoaded();
return this._postDate;
}
}
protected override void doFromHash(Dictionary<string, string> data) {
this._title = data[TableSpec.FIELD_TITLE];
this._isDetailed = Util.string2bool(data[TableSpec.FIELD_ISDETAILED]);
this._isMultiOption = Util.string2bool(data[TableSpec.FIELD_ISMULTIOPTION]);
this._options = (from elem in XElement.Parse(data[TableSpec.FIELD_OPTIONS]).Descendants("option") select new KeyValuePair<int, string>(int.Parse(elem.Attribute("id").Value), elem.Attribute("name").Value)).ToDictionary();
this._posterId = int.Parse(data[TableSpec.FIELD_POSTERID]);
this._postDate = Util.ParseDateTimeFromTimestamp(data[TableSpec.FIELD_POSTDATE]).Value;
}
public XElement exportToXml(UserContext context) {
return new XElement("poll",
new XElement("id", this.id),
new XElement("title", this.title),
new XElement("isDetailed", this.isDetailed.ToPlainString()),
new XElement("isMultiOption", this.isMultiOption.ToPlainString()),
new XElement(
"options",
from kvp in this.options
select new XElement(
"option",
new XElement("id", kvp.Key),
new XElement("name", kvp.Value)
)
),
new XElement("poster", this.poster.exportToXmlForViewing(context)),
new XElement("postDate", this.postDate.ToXml())
);
}
private Dictionary<int, PollOptionInfo> GetOptionsWithVotes(User user) {
Dictionary<int, PollOptionInfo> result = this.options.ToDictionary(kvp => kvp.Key, kvp => new PollOptionInfo { name = kvp.Value, votes = 0, voters = new List<int>(), selected = false });
foreach(
var vote
in
Vote.LoadByIds(
from stringId in Config.instance.mainConnection.LoadIdsByConditions(
Vote.TableSpec.instance,
new ComparisonCondition(
Vote.TableSpec.instance.getColumnSpec(Vote.TableSpec.FIELD_POLLID),
ComparisonType.EQUAL,
this.id.ToString()
),
Diapasone.unlimited
) select int.Parse(stringId)
)
) {
foreach(int optionId in vote.options) {
result[optionId].votes += 1;
if(this.isDetailed) {
result[optionId].voters.Add(vote.userId);
}
}
if(user != null && vote.user.id == user.id) {
foreach(int optionId in vote.options) {
result[optionId].selected = true;
}
}
}
return result;
}
public XElement exportToXmlWithVotes(UserContext context) {
return new XElement("poll",
new XElement("id", this.id),
new XElement("title", this.title),
new XElement("isDetailed", this.isDetailed.ToPlainString()),
new XElement("isMultiOption", this.isMultiOption.ToPlainString()),
new XElement(
"options",
from kvp in this.GetOptionsWithVotes((context.account != null) ? context.account.user : null)
select new XElement(
"option",
new XElement("id", kvp.Key),
new XElement("name", kvp.Value.name),
new XElement("isSelected", kvp.Value.selected),
new XElement("votes", kvp.Value.votes),
new XElement(
"voters",
from userId in kvp.Value.voters select User.LoadById(userId).exportToXmlForViewing(context)
)
),
new XElement(
"total",
Config.instance.mainConnection.GetCountByConditions(
Vote.TableSpec.instance,
new ComparisonCondition(
Vote.TableSpec.instance.getColumnSpec(Vote.TableSpec.FIELD_POLLID),
ComparisonType.EQUAL,
this.id.ToString()
)
)
)
),
new XElement("poster", this.poster.exportToXmlForViewing(context)),
new XElement("postDate", this.postDate.ToXml())
);
}
public void GiveVote(User user, HashSet<int> options) {
foreach(int option in options) {
if(!this.options.ContainsKey(option)) throw new CriticalException("invalid option");
}
AbstractFieldValue voteInfo = new ScalarFieldValue(
new XElement("votes",
from option in options select new XElement("vote", new XAttribute("optionId", option))
).ToString()
);
ChangeSetUtil.ApplyChanges(
new InsertOrUpdateChange(
Vote.TableSpec.instance,
new Dictionary<string,AbstractFieldValue> {
{ Vote.TableSpec.FIELD_POLLID, new ScalarFieldValue(this.id.ToString()) },
{ Vote.TableSpec.FIELD_USERID, new ScalarFieldValue(user.id.ToString()) },
{ Vote.TableSpec.FIELD_VOTEINFO, voteInfo }
},
new Dictionary<string,AbstractFieldValue> {
{ Vote.TableSpec.FIELD_VOTEINFO, voteInfo },
},
new ComplexCondition(
ConditionsJoinType.AND,
new ComparisonCondition(
Vote.TableSpec.instance.getColumnSpec(Vote.TableSpec.FIELD_POLLID),
ComparisonType.EQUAL,
this.id.ToString()
),
new ComparisonCondition(
Vote.TableSpec.instance.getColumnSpec(Vote.TableSpec.FIELD_USERID),
ComparisonType.EQUAL,
user.id.ToString()
)
)
)
);
}
public static Poll Create(User poster, bool isDetailed, bool isMultiOption, string titleUbb, List<string> optionsUbb) {
List<XElement> options = new List<XElement>();
for(int i=0; i<optionsUbb.Count; i++) {
options.Add(
new XElement(
"option",
new XAttribute("id", i+1),
new XAttribute("name", UBBParser.UBBToIntermediate(optionsUbb[i]))
)
);
}
AbstractChange pollInsert = new InsertChange(
TableSpec.instance,
new Dictionary<string,AbstractFieldValue> {
{ TableSpec.FIELD_ISDETAILED, new ScalarFieldValue(isDetailed ? "1" : "0") },
{ TableSpec.FIELD_ISMULTIOPTION, new ScalarFieldValue(isMultiOption ? "1" : "0") },
{ TableSpec.FIELD_POSTERID, new ScalarFieldValue(poster.id.ToString()) },
{ TableSpec.FIELD_POSTDATE, new ScalarFieldValue(DateTime.Now.ToUTCString()) },
{ TableSpec.FIELD_TITLE, new ScalarFieldValue(UBBParser.UBBToIntermediate(titleUbb)) },
{ TableSpec.FIELD_OPTIONS, new ScalarFieldValue((new XElement("options", options)).ToString()) },
}
);
ChangeSetUtil.ApplyChanges(pollInsert);
return Poll.LoadById(pollInsert.getId().Value);
}
}
}

@ -124,6 +124,16 @@ namespace FLocal.IISHandler {
default:
return new handlers.WrongUrlHandler();
}
case "poll":
if(context.requestParts.Length < 2) {
return new handlers.WrongUrlHandler();
}
switch(context.requestParts[1].ToLower()) {
case "create":
return new handlers.response.CreatePollHandler();
default:
return new handlers.response.PollHandler();
}
case "static":
return new handlers.StaticHandler(context.requestParts);
case "do":
@ -151,6 +161,10 @@ namespace FLocal.IISHandler {
return new handlers.request.MarkThreadAsReadHandler();
case "upload":
return new handlers.request.UploadHandler();
case "newpoll":
return new handlers.request.CreatePollHandler();
case "vote":
return new handlers.request.VoteHandler();
default:
return new handlers.WrongUrlHandler();
}

@ -60,6 +60,7 @@
<Compile Include="handlers\PostHandler.cs" />
<Compile Include="handlers\request\AbstractNewMessageHandler.cs" />
<Compile Include="handlers\request\AbstractPostHandler.cs" />
<Compile Include="handlers\request\CreatePollHandler.cs" />
<Compile Include="handlers\request\CreateThreadHandler.cs" />
<Compile Include="handlers\request\EditHandler.cs" />
<Compile Include="handlers\request\LoginHandler.cs" />
@ -71,11 +72,13 @@
<Compile Include="handlers\request\SendPMHandler.cs" />
<Compile Include="handlers\request\SettingsHandler.cs" />
<Compile Include="handlers\request\UploadHandler.cs" />
<Compile Include="handlers\request\VoteHandler.cs" />
<Compile Include="handlers\response\ActiveAccountListHandler.cs" />
<Compile Include="handlers\response\AllPostsHandler.cs" />
<Compile Include="handlers\response\BoardAsThread.cs" />
<Compile Include="handlers\response\ConversationHandler.cs" />
<Compile Include="handlers\response\ConversationsHandler.cs" />
<Compile Include="handlers\response\CreatePollHandler.cs" />
<Compile Include="handlers\response\CreateThreadHandler.cs" />
<Compile Include="handlers\response\EditHandler.cs" />
<Compile Include="handlers\response\LegacyPHPHandler.cs" />
@ -85,6 +88,7 @@
<Compile Include="handlers\response\PMReplyHandler.cs" />
<Compile Include="handlers\response\PMReplyToPostHandler.cs" />
<Compile Include="handlers\response\PMSendHandler.cs" />
<Compile Include="handlers\response\PollHandler.cs" />
<Compile Include="handlers\response\QuickLinkHandler.cs" />
<Compile Include="handlers\response\RedirectGetHandler.cs" />
<Compile Include="handlers\response\ReplyHandler.cs" />

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using FLocal.Core;
using FLocal.Common.dataobjects;
namespace FLocal.IISHandler.handlers.request {
class CreatePollHandler : AbstractPostHandler {
protected override string templateName {
get {
return "result/PollCreated.xslt";
}
}
protected override XElement[] Do(WebContext context) {
string title = context.httprequest.Form["title"].Trim();
if(title == "") throw new FLocalException("title is empty");
string[] rawOptions = context.httprequest.Form.GetValues("option");
List<string> options = new List<string>();
foreach(string rawOption in rawOptions) {
if(rawOption != null && rawOption.Trim() != "") {
options.Add(rawOption.Trim());
}
}
if(options.Count < 2) throw new FLocalException("Only " + options.Count + " options is entered");
bool isDetailed = context.httprequest.Form.AllKeys.Contains("isDetailed");
bool isMultiOption = context.httprequest.Form.AllKeys.Contains("isMultiOption");
Poll poll = Poll.Create(
context.session.account.user,
isDetailed,
isMultiOption,
title,
options
);
return new XElement[] {
poll.exportToXml(context),
};
}
}
}

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using FLocal.Core;
using FLocal.Common.dataobjects;
namespace FLocal.IISHandler.handlers.request {
class VoteHandler : AbstractPostHandler {
protected override string templateName {
get {
return "result/VoteAccepted.xslt";
}
}
protected override XElement[] Do(WebContext context) {
Poll poll = Poll.LoadById(int.Parse(context.httprequest.Form["pollId"]));
string[] rawOptions = context.httprequest.Form.GetValues("option");
HashSet<int> options = new HashSet<int>();
foreach(string rawOption in rawOptions) {
options.Add(int.Parse(rawOption));
}
if(!poll.isMultiOption && options.Count > 1) {
throw new FLocalException(options.Count + " options selected in a single-option poll");
}
poll.GiveVote(context.session.account.user, options);
return new XElement[] {
poll.exportToXml(context),
};
}
}
}

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Xml.Linq;
using FLocal.Core;
using FLocal.Common;
using FLocal.Common.dataobjects;
namespace FLocal.IISHandler.handlers.response {
class CreatePollHandler : AbstractGetHandler {
override protected string templateName {
get {
return "NewPoll.xslt";
}
}
override protected XElement[] getSpecificData(WebContext context) {
return new XElement[] {
};
}
}
}

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Xml.Linq;
using FLocal.Common;
using FLocal.Common.dataobjects;
using FLocal.Core;
using FLocal.Core.DB;
using FLocal.Core.DB.conditions;
namespace FLocal.IISHandler.handlers.response {
class PollHandler : AbstractGetHandler {
override protected string templateName {
get {
return "Poll.xslt";
}
}
override protected XElement[] getSpecificData(WebContext context) {
Poll poll = Poll.LoadById(int.Parse(context.requestParts[1]));
return new XElement[] {
poll.exportToXmlWithVotes(context)
};
}
}
}

@ -0,0 +1,192 @@
<?xml version="1.0" encoding="Windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:import href="elems\Main.xslt"/>
<xsl:import href="elems\TextEditor.xslt"/>
<xsl:template name="specificTitle">
<xsl:text>Íîâûé îïîðîñ</xsl:text>
</xsl:template>
<xsl:template name="specific">
<table width="95%" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr>
<td>
<table cellpadding="3" cellspacing="1" width="100%" class="tableborders">
<tr>
<td class="tdheader">
<xsl:text>Ñîçäàíèå íîâîãî îïðîñà</xsl:text>
</td>
</tr>
<tr class="darktable">
<td>
<xsl:text>Çàïîëíèòå ïðèâåäåííóþ íèæå ôîðìó äëÿ îòïðàâêè ñîîáùåíèÿ â ôîðóì. HTML îòêëþ÷åí. UBBCode âêëþ÷åí, è âû ìîæåòå èñïîëüçîâàòü UBBCode â âàøèõ ñîîáùåíèÿõ. Àíîíèìíûå ñîîáùåíèÿ ðàçðåøåíû, è âû ìîæåòå âûáðàòü ëþáîå íåçàðåãèñòðèðîâàííîå èìÿ.</xsl:text>
</td>
</tr>
<tr>
<td class="lighttable">
<form method="post" action="/do/NewPoll/" name="replier">
<xsl:text>Ïîëüçîâàòåëü: </xsl:text>
<xsl:value-of select="session/user/name"/>
<br/>
<br/>
<xsl:text>Òåìà: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="title">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<input type="checkbox" name="isDetailed" value="isDetailed"/><label for="isDetailed"> Ïîêàçûâàòü èìåíà ïðîãîëîñîâàâøèõ</label>
<br/>
<input type="checkbox" name="isMultiOption" value="isMultiOption"/><label for="isMultiOption"> Ðàçðåøèòü âûáîð íåñêîëüêèõ âàðèàíòîâ</label>
<br/>
<br/>
<xsl:text>Âàðèàíò 1: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 2: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 3: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 4: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 5: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 6: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 7: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 8: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 9: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 10: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 11: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 12: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 13: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 14: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 15: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 16: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 17: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 18: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 19: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<xsl:text>Âàðèàíò 20: </xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="3" class="formboxes" name="option">
<xsl:text> </xsl:text>
</textarea>
<br/>
<br/>
<input type="submit" tabindex="3" name="textcont" taborder="2" value="Ïðîäîëæèòü" class="buttons"/>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="Windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:import href="elems\Main.xslt"/>
<xsl:import href="elems\PollInfo.xslt"/>
<xsl:template name="specificTitle">
<xsl:value-of select="poll/title"/>
</xsl:template>
<xsl:template name="specific">
<table width="95%" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr>
<td>
<table cellpadding="3" cellspacing="1" width="100%" class="tableborders">
<tr class="darktable">
<td>
<table width="100%" cellpadding="0" cellspacing="0">
<tr class="darktable">
<td align="left" width="33%">
<font class="catandforum">
<xsl:text>Îïðîñû</xsl:text>
<xsl:text> &gt;&gt; </xsl:text>
<xsl:value-of select="poll/title"/>
</font>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br />
<table width="95%" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr>
<td>
<table cellpadding="0" cellspacing="1" width="100%" class="tableborders">
<xsl:apply-templates select="poll"/>
</table>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>

@ -0,0 +1,167 @@
<?xml version="1.0" encoding="Windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:import href="UserInfoBar.xslt"/>
<xsl:template match="poll">
<tr>
<td>
<table width="100%" cellspacing="1" cellpadding="3" border="0">
<tr>
<td width="120" valign="top" class="darktable" rowspan="2">
<xsl:apply-templates select="poster" mode="userInfoBar"/>
</td>
<td class="subjecttable">
<a target="_blank" class="separate">
<img border="0" src="/static/images/message-normal-read.gif" alt="" style="vertical-align: text-bottom" />
</a>
<b class="separate"><xsl:value-of select="title" disable-output-escaping="yes"/></b>
<br />
<font class="small" style="padding-left:2em"><xsl:apply-templates select="postDate/date" mode="dateTime"/></font>
</td>
</tr>
<tr>
<td class="lighttable">
<table width="100%" cellspacing="0" cellpadding="0" style="table-layout: fixed">
<tr>
<td>
<font class="post">
<form action="/do/Vote/" method="POST">
<input type="hidden" name="pollId">
<xsl:attribute name="value"><xsl:value-of select="id"/></xsl:attribute>
</input>
<h2><xsl:value-of select="title" disable-output-escaping="yes"/></h2>
<p>
<xsl:choose>
<xsl:when test="isDetailed='true'">
<xsl:text>Äåòàëèçàöèÿ ïî ãîëîñàì â ýòîì îïðîñå îòêðûòà</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Ýòî àíîíèìíûé îïðîñ</xsl:text>
</xsl:otherwise>
</xsl:choose>
</p>
<p>
<xsl:choose>
<xsl:when test="isMultiOption='true'">
<xsl:text>Ýòîò îïðîñ äîïóñêàåò âûáîð íåñêîëüêèõ âàðèàíòîâ îòâåòà</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Ýòîò îïðîñ äîïóñêàåò âûáîð òîëüêî îäíîãî âàðèàíòà îòâåòà</xsl:text>
</xsl:otherwise>
</xsl:choose>
</p>
<p>
<xsl:text>Âñåãî ãîëîñîâ: </xsl:text>
<xsl:value-of select="options/total"/>
</p>
<table border="2" width="100%">
<xsl:apply-templates select="options/option">
<xsl:with-param name="inputType">
<xsl:choose>
<xsl:when test="isMultiOption='true'">
<xsl:text>checkbox</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>radio</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="totalVotes">
<xsl:value-of select="options/total"/>
</xsl:with-param>
</xsl:apply-templates>
</table>
<input type="submit" value="Ïðîãîëîñîâàòü"/>
</form>
<br/>
<br/>
<xsl:text>Äëÿ âñòàâêè ññûëêè â ôîðóì èñïîëüçóéòå òýã [poll]</xsl:text>
<xsl:value-of select="id"/>
<xsl:text>[/poll]</xsl:text>
</font>
</td>
</tr>
<xsl:if test="poster/user/signature != ''">
<tr>
<td>
<div style="width:100%;max-height:50px;height: expression( this.scrollHeight > 49 ? '50px' : 'auto' );overflow:hidden">
<font size="-2"><xsl:value-of select="poster/user/signature"/><br /></font>
</div>
</td>
</tr>
</xsl:if>
</table>
</td>
</tr>
</table>
</td>
</tr>
</xsl:template>
<xsl:template match="option">
<xsl:param name="inputType">radio</xsl:param>
<xsl:param name="totalVotes">0</xsl:param>
<tr>
<td width="50%">
<input name="option">
<xsl:attribute name="type"><xsl:value-of select="$inputType"/></xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="id"/></xsl:attribute>
<xsl:if test="isSelected='true'">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
<xsl:if test="not(/root/session/sessionKey)">
<xsl:attribute name="disabled">disabled</xsl:attribute>
</xsl:if>
</input>
<label for="option">
<xsl:text> </xsl:text>
<xsl:value-of select="name" disable-output-escaping="yes"/>
</label>
</td>
<td width="50%">
<div class="pollcolor">
<xsl:attribute name="style">
<xsl:text>height:1em;</xsl:text>
<xsl:text>width:</xsl:text>
<xsl:choose>
<xsl:when test="votes &gt; 0">
<xsl:value-of select="round(100 * votes div $totalVotes)"/>
<xsl:text>%</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>3px</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:text> </xsl:text>
</div>
<p>
<xsl:value-of select="votes"/>
<xsl:text> ãîëîñîâ (</xsl:text>
<xsl:choose>
<xsl:when test="votes &gt; 0">
<xsl:value-of select="round(100 * votes div $totalVotes)"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>%)</xsl:text>
</p>
<xsl:if test="voters/user">
<p>
<xsl:apply-templates select="voters/user" mode="userLink"/>
</p>
</xsl:if>
</td>
</tr>
</xsl:template>
<xsl:template match="user" mode="userLink">
<a class="separate">
<xsl:attribute name="href">/User/<xsl:value-of select="id"/>/</xsl:attribute>
<xsl:value-of select="name"/>
</a>
</xsl:template>
</xsl:stylesheet>

@ -124,6 +124,7 @@ function insertInBody(str) {
</td>
</tr>
<tr>
<!--
<td class="darktable">
<a pseudolink="pseudolink" onclick="alert('Not implemented');return;DoPrompt('pollstart');">Íà÷àëî<br/>ãîëîñîâàíèÿ</a>
</td>
@ -133,6 +134,10 @@ function insertInBody(str) {
<td class="darktable">
<a pseudolink="pseudolink" onclick="alert('Not implemented');return;DoPrompt('pollstop');">Êîíåö<br/>ãîëîñîâàíèÿ</a>
</td>
-->
<td class="darktable" colspan="3" align="center">
<a href="/Poll/Create/">Ńîçäŕňü îďđîń</a>
</td>
</tr>
<tr>
<td class="darktable">

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="Windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:import href="..\elems\Main.xslt"/>
<xsl:template name="specificTitle">Îïðîñ ñîçäàí</xsl:template>
<xsl:template name="specific">
<table width="95%" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr>
<td>
<table cellpadding="3" cellspacing="1" width="100%" class="tableborders">
<tr>
<td class="tdheader">
<xsl:text>Ñîçäàíèå îïðîñà</xsl:text>
</td>
</tr>
<tr>
<td class="lighttable">
<xsl:text>Îïðîñ óñïåøíî ñîçäàí.</xsl:text>
<br/>
<xsl:text>Òåïåðü âû ìîæåòå âñòàâëÿòü ññûëêè íà íåãî ñ ïîìîùüþ òýãà [poll]</xsl:text>
<xsl:value-of select="poll/id"/>
<xsl:text>[/poll]</xsl:text>
<br/>
<a>
<xsl:attribute name="href">/Poll/<xsl:value-of select="poll/id"/>/</xsl:attribute>
<xsl:text>Ïåðåéòè ê îïðîñó</xsl:text>
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="Windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:import href="..\elems\Main.xslt"/>
<xsl:template name="specificTitle">Ãîëîñ ïðèíÿò</xsl:template>
<xsl:template name="specific">
<table width="95%" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr>
<td>
<table cellpadding="3" cellspacing="1" width="100%" class="tableborders">
<tr>
<td class="tdheader">
<xsl:text>Ó÷àñòèå â îïðîñå</xsl:text>
</td>
</tr>
<tr>
<td class="lighttable">
<xsl:text>Âàø ãîëîñ ïðèíÿò.</xsl:text>
<br/>
<a>
<xsl:attribute name="href">/Poll/<xsl:value-of select="poll/id"/>/</xsl:attribute>
<xsl:text>Âåðíóòüñÿ ê îïðîñó</xsl:text>
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
Loading…
Cancel
Save