1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.MonoRail
.ActiveRecordScaffold
.Helpers
18 using System
.Collections
;
19 using Castle
.ActiveRecord
.Framework
.Internal
;
20 using Castle
.MonoRail
.Framework
.Helpers
;
22 public class PresentationHelper
: AbstractHelper
24 public String
StartAlternateTR(int index
, String styleClass
, String altStyleClass
)
26 return String
.Format("<tr class=\"{0}\">", index
% 2 == 0 ? styleClass
: altStyleClass
);
29 public String
BestAlignFor(Type type
)
31 if (type
== typeof(String
))
39 public String
LinkToBack(String text
, IDictionary attributes
)
41 return String
.Format( "<a href=\"javascript:history.go(-1);\" {1}>{0}</a>",
42 text
, GetAttributes(attributes
) );
45 public String
LinkToList(ActiveRecordModel model
, bool useModelName
, String text
, IDictionary attributes
)
49 return String
.Format("<a href=\"list{0}.{1}\" {3}>{2}</a>", model
.Type
.Name
,
50 Controller
.Context
.UrlInfo
.Extension
, text
, GetAttributes(attributes
));
54 return String
.Format("<a href=\"list.{0}\" {2}>{1}</a>",
55 Controller
.Context
.UrlInfo
.Extension
, text
, GetAttributes(attributes
));
59 public String
LinkToNew(ActiveRecordModel model
, bool useModelName
, String text
, IDictionary attributes
)
63 return String
.Format("<a href=\"new{0}.{1}\" {3}>{2}</a>", model
.Type
.Name
,
64 Controller
.Context
.UrlInfo
.Extension
, text
, GetAttributes(attributes
));
68 return String
.Format("<a href=\"new.{0}\" {2}>{1}</a>",
69 Controller
.Context
.UrlInfo
.Extension
, text
, GetAttributes(attributes
));
73 public String
LinkToEdit(ActiveRecordModel model
, bool useModelName
,
74 String text
, object key
, IDictionary attributes
)
78 return String
.Format("<a href=\"edit{0}.{1}?id={4}\" {3}>{2}</a>", model
.Type
.Name
,
79 Controller
.Context
.UrlInfo
.Extension
, text
, GetAttributes(attributes
), key
);
83 return String
.Format("<a href=\"edit.{0}?id={3}\" {2}>{1}</a>",
84 Controller
.Context
.UrlInfo
.Extension
, text
, GetAttributes(attributes
), key
);
88 public String
LinkToConfirm(ActiveRecordModel model
, bool useModelName
, String text
, object key
, IDictionary attributes
)
92 return String
.Format("<a href=\"confirm{0}.{1}?id={4}\" {3}>{2}</a>", model
.Type
.Name
,
93 Controller
.Context
.UrlInfo
.Extension
, text
, GetAttributes(attributes
), key
);
97 return String
.Format("<a href=\"confirm.{0}?id={3}\" {2}>{1}</a>",
98 Controller
.Context
.UrlInfo
.Extension
, text
, GetAttributes(attributes
), key
);
102 public String
LinkToRemove(ActiveRecordModel model
, bool useModelName
, String text
, object key
, IDictionary attributes
)
106 return String
.Format("<a href=\"remove{0}.{1}?id={4}\" {3}>{2}</a>", model
.Type
.Name
,
107 Controller
.Context
.UrlInfo
.Extension
, text
, GetAttributes(attributes
), key
);
111 return String
.Format("<a href=\"remove.{0}?id={3}\" {2}>{1}</a>",
112 Controller
.Context
.UrlInfo
.Extension
, text
, GetAttributes(attributes
), key
);