lipsiadmin 4.1.8 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. data/CHANGELOG +41 -2
  2. data/lib/access_control/authentication.rb +1 -1
  3. data/lib/access_control/base.rb +18 -11
  4. data/lib/controller/ext.rb +5 -3
  5. data/lib/controller/pdf_builder.rb +22 -6
  6. data/lib/controller/responds_to_parent.rb +1 -1
  7. data/lib/data_base/attachment_table.rb +0 -1
  8. data/lib/lipsiadmin.rb +7 -0
  9. data/lib/mailer/pdf_builder.rb +23 -9
  10. data/lib/version.rb +3 -3
  11. data/lib/view/helpers/backend_helper.rb +137 -97
  12. data/lib/view/helpers/ext/button.rb +62 -0
  13. data/lib/view/helpers/ext/column_model.rb +29 -23
  14. data/lib/view/helpers/ext/component.rb +52 -40
  15. data/lib/view/helpers/ext/configuration.rb +3 -2
  16. data/lib/view/helpers/ext/grid.rb +38 -40
  17. data/lib/view/helpers/ext/store.rb +12 -12
  18. data/lib/view/helpers/ext/templates/grid_functions.js.erb +14 -9
  19. data/lib/view/helpers/ext/tool_bar.rb +9 -10
  20. data/lib/view/helpers/ext_helper.rb +3 -2
  21. data/lib/view/helpers/pdf_helper.rb +45 -0
  22. data/lipsiadmin_generators/attachment/REMEMBER +0 -4
  23. data/lipsiadmin_generators/attachment/templates/migration.rb +1 -1
  24. data/lipsiadmin_generators/backend/templates/config/config.yml +2 -3
  25. data/lipsiadmin_generators/backend/templates/config/locales/backend/en.yml +2 -0
  26. data/lipsiadmin_generators/backend/templates/config/locales/backend/it.yml +2 -0
  27. data/lipsiadmin_generators/backend/templates/config/locales/models/{en.yml → account/en.yml} +0 -0
  28. data/lipsiadmin_generators/backend/templates/config/locales/models/{it.yml → account/it.yml} +0 -0
  29. data/lipsiadmin_generators/backend/templates/controllers/javascripts_controller.rb +1 -1
  30. data/lipsiadmin_generators/backend/templates/images/backend/association_break.png +0 -0
  31. data/lipsiadmin_generators/backend/templates/images/backend/association_ok.png +0 -0
  32. data/lipsiadmin_generators/backend/templates/images/backend/categories.gif +0 -0
  33. data/lipsiadmin_generators/backend/templates/images/ext/charts.swf +0 -0
  34. data/lipsiadmin_generators/backend/templates/images/ext/{slate/sizer/se-handle.gif → default/button/arrow.gif} +0 -0
  35. data/lipsiadmin_generators/backend/templates/images/ext/default/button/btn.gif +0 -0
  36. data/lipsiadmin_generators/backend/templates/images/ext/default/button/group-cs.gif +0 -0
  37. data/lipsiadmin_generators/backend/templates/images/ext/{slate/grid/grid-blue-split.gif → default/button/group-lr.gif} +0 -0
  38. data/lipsiadmin_generators/backend/templates/images/ext/{slate/grid/arrow-right-white.gif → default/button/group-tb.gif} +0 -0
  39. data/lipsiadmin_generators/backend/templates/images/ext/default/button/s-arrow-b-noline.gif +0 -0
  40. data/lipsiadmin_generators/backend/templates/images/ext/default/button/s-arrow-b.gif +0 -0
  41. data/lipsiadmin_generators/backend/templates/images/ext/default/button/s-arrow-bo.gif +0 -0
  42. data/lipsiadmin_generators/backend/templates/images/ext/{slate/grid/grid3-hrow.gif → default/button/s-arrow-noline.gif} +0 -0
  43. data/lipsiadmin_generators/backend/templates/images/ext/default/button/s-arrow-o.gif +0 -0
  44. data/lipsiadmin_generators/backend/templates/images/ext/default/button/s-arrow.gif +0 -0
  45. data/lipsiadmin_generators/backend/templates/images/ext/default/form/checkbox.gif +0 -0
  46. data/lipsiadmin_generators/backend/templates/images/ext/default/form/radio.gif +0 -0
  47. data/lipsiadmin_generators/backend/templates/images/ext/default/form/trigger.gif +0 -0
  48. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/group-collapse.gif +0 -0
  49. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/group-expand.gif +0 -0
  50. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/refresh.gif +0 -0
  51. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/sort-hd.gif +0 -0
  52. data/lipsiadmin_generators/backend/templates/images/ext/default/panel/tool-sprites.gif +0 -0
  53. data/lipsiadmin_generators/backend/templates/images/ext/default/panel/tools-sprites-trans.gif +0 -0
  54. data/lipsiadmin_generators/backend/templates/images/ext/default/qtip/tip-anchor-sprite.gif +0 -0
  55. data/lipsiadmin_generators/backend/templates/images/ext/default/shadow-c.png +0 -0
  56. data/lipsiadmin_generators/backend/templates/images/ext/default/slider/slider-bg.png +0 -0
  57. data/lipsiadmin_generators/backend/templates/images/ext/default/slider/slider-thumb.png +0 -0
  58. data/lipsiadmin_generators/backend/templates/images/ext/default/slider/slider-v-bg.png +0 -0
  59. data/lipsiadmin_generators/backend/templates/images/ext/default/slider/slider-v-thumb.png +0 -0
  60. data/lipsiadmin_generators/backend/templates/images/ext/{slate/grid/arrow-left-white.gif → default/toolbar/more.gif} +0 -0
  61. data/lipsiadmin_generators/backend/templates/images/ext/default/toolbar/tb-xl-btn-sprite.gif +0 -0
  62. data/lipsiadmin_generators/backend/templates/images/ext/{slate/panel/left-right.gif → default/toolbar/tb-xl-sep.gif} +0 -0
  63. data/lipsiadmin_generators/backend/templates/images/ext/default/window/left-corners.png +0 -0
  64. data/lipsiadmin_generators/backend/templates/images/ext/default/window/left-right.png +0 -0
  65. data/lipsiadmin_generators/backend/templates/images/ext/default/window/left-right.psd +0 -0
  66. data/lipsiadmin_generators/backend/templates/images/ext/default/window/right-corners.png +0 -0
  67. data/lipsiadmin_generators/backend/templates/images/ext/default/window/top-bottom.png +0 -0
  68. data/lipsiadmin_generators/backend/templates/images/ext/default/window/top-bottom.psd +0 -0
  69. data/lipsiadmin_generators/backend/templates/images/ext/expressinstall.swf +0 -0
  70. data/lipsiadmin_generators/backend/templates/javascripts/ext.js +97 -76
  71. data/lipsiadmin_generators/backend/templates/javascripts/prototype.js +14 -12
  72. data/lipsiadmin_generators/backend/templates/models/notifier.rb +1 -1
  73. data/lipsiadmin_generators/backend/templates/stylesheets/backend.css +11 -2
  74. data/lipsiadmin_generators/backend/templates/stylesheets/ext.css +1070 -546
  75. data/lipsiadmin_generators/backend/templates/stylesheets/login.css +1 -0
  76. data/lipsiadmin_generators/backend/templates/views/backend/accounts/index.rjs +1 -0
  77. data/lipsiadmin_generators/backend/templates/views/backend/base/index.html.haml +7 -4
  78. data/lipsiadmin_generators/backend/templates/views/javascripts/backend.js.erb +203 -143
  79. data/lipsiadmin_generators/pdf/pdf_generator.rb +1 -4
  80. data/lipsiadmin_generators/pdf/templates/view.html.haml +11 -6
  81. data/lipsiadmin_generators/state_session/state_session_generator.rb +2 -0
  82. data/resources/javascripts/ux.js +16 -17
  83. data/resources/javascripts/ux.min.js +2 -0
  84. data/resources/pd4ml/ruby/Pd4Ruby.class +0 -0
  85. data/resources/pd4ml/ruby/Pd4Ruby.java +277 -31
  86. data/tasks/lipsiadmin_tasks.rake +18 -1
  87. metadata +32 -124
  88. data/lipsiadmin_generators/backend/templates/images/ext/default/box/tb-slate.gif +0 -0
  89. data/lipsiadmin_generators/backend/templates/images/ext/default/button/btn-arrow.gif +0 -0
  90. data/lipsiadmin_generators/backend/templates/images/ext/default/button/btn-sprite.gif +0 -0
  91. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/Thumbs.db +0 -0
  92. data/lipsiadmin_generators/backend/templates/images/ext/slate/button/btn-arrow.gif +0 -0
  93. data/lipsiadmin_generators/backend/templates/images/ext/slate/button/btn-sprite.gif +0 -0
  94. data/lipsiadmin_generators/backend/templates/images/ext/slate/editor/tb-sprite.gif +0 -0
  95. data/lipsiadmin_generators/backend/templates/images/ext/slate/form/checkbox.gif +0 -0
  96. data/lipsiadmin_generators/backend/templates/images/ext/slate/form/clear-trigger.gif +0 -0
  97. data/lipsiadmin_generators/backend/templates/images/ext/slate/form/date-trigger.gif +0 -0
  98. data/lipsiadmin_generators/backend/templates/images/ext/slate/form/radio.gif +0 -0
  99. data/lipsiadmin_generators/backend/templates/images/ext/slate/form/search-trigger.gif +0 -0
  100. data/lipsiadmin_generators/backend/templates/images/ext/slate/form/trigger-tpl.gif +0 -0
  101. data/lipsiadmin_generators/backend/templates/images/ext/slate/form/trigger.gif +0 -0
  102. data/lipsiadmin_generators/backend/templates/images/ext/slate/gradient-bg.gif +0 -0
  103. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/col-move-bottom.gif +0 -0
  104. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/col-move-top.gif +0 -0
  105. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/footer-bg.gif +0 -0
  106. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid-blue-hd.gif +0 -0
  107. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid-hrow.gif +0 -0
  108. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid-split.gif +0 -0
  109. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid-vista-hd.gif +0 -0
  110. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid3-hd-btn.gif +0 -0
  111. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid3-hrow-over.gif +0 -0
  112. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid3-special-col-bg.gif +0 -0
  113. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid3-special-col-sel-bg.gif +0 -0
  114. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/group-expand-sprite.gif +0 -0
  115. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/mso-hd.gif +0 -0
  116. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-first-disabled.gif +0 -0
  117. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-first.gif +0 -0
  118. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-last-disabled.gif +0 -0
  119. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-last.gif +0 -0
  120. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-next-disabled.gif +0 -0
  121. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-next.gif +0 -0
  122. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-prev-disabled.gif +0 -0
  123. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-prev.gif +0 -0
  124. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/refresh.gif +0 -0
  125. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/row-over.gif +0 -0
  126. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/row-sel.gif +0 -0
  127. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/sort_asc.gif +0 -0
  128. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/sort_desc.gif +0 -0
  129. data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/checked.gif +0 -0
  130. data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/group-checked.gif +0 -0
  131. data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/item-over - Copy.gif +0 -0
  132. data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/item-over.gif +0 -0
  133. data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/menu-parent.gif +0 -0
  134. data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/menu.gif +0 -0
  135. data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/unchecked.gif +0 -0
  136. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/corners-sprite.gif +0 -0
  137. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/light-hd.gif +0 -0
  138. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/tool-sprite-tpl.gif +0 -0
  139. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/tool-sprites.gif +0 -0
  140. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/tools-sprites-trans.gif +0 -0
  141. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/top-bottom.gif +0 -0
  142. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/top-bottom.png +0 -0
  143. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/white-corners-sprite.gif +0 -0
  144. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/white-left-right.gif +0 -0
  145. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/white-top-bottom.gif +0 -0
  146. data/lipsiadmin_generators/backend/templates/images/ext/slate/progress/progress-bg.gif +0 -0
  147. data/lipsiadmin_generators/backend/templates/images/ext/slate/qtip/bg.gif +0 -0
  148. data/lipsiadmin_generators/backend/templates/images/ext/slate/qtip/close.gif +0 -0
  149. data/lipsiadmin_generators/backend/templates/images/ext/slate/qtip/tip-sprite.gif +0 -0
  150. data/lipsiadmin_generators/backend/templates/images/ext/slate/s.gif +0 -0
  151. data/lipsiadmin_generators/backend/templates/images/ext/slate/shared/glass-bg.gif +0 -0
  152. data/lipsiadmin_generators/backend/templates/images/ext/slate/shared/hd-sprite.gif +0 -0
  153. data/lipsiadmin_generators/backend/templates/images/ext/slate/shared/left-btn.gif +0 -0
  154. data/lipsiadmin_generators/backend/templates/images/ext/slate/shared/right-btn.gif +0 -0
  155. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/e-handle-dark.gif +0 -0
  156. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/e-handle.gif +0 -0
  157. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/ne-handle-dark.gif +0 -0
  158. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/ne-handle.gif +0 -0
  159. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/nw-handle-dark.gif +0 -0
  160. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/nw-handle.gif +0 -0
  161. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/s-handle-dark.gif +0 -0
  162. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/s-handle.gif +0 -0
  163. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/se-handle-dark.gif +0 -0
  164. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/square.gif +0 -0
  165. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/sw-handle-dark.gif +0 -0
  166. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/sw-handle.gif +0 -0
  167. data/lipsiadmin_generators/backend/templates/images/ext/slate/slider/slider-bg.png +0 -0
  168. data/lipsiadmin_generators/backend/templates/images/ext/slate/slider/slider-thumb.png +0 -0
  169. data/lipsiadmin_generators/backend/templates/images/ext/slate/slider/slider-v-bg.png +0 -0
  170. data/lipsiadmin_generators/backend/templates/images/ext/slate/slider/slider-v-thumb.png +0 -0
  171. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/scroll-left.gif +0 -0
  172. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/scroll-right.gif +0 -0
  173. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/scroller-bg.gif +0 -0
  174. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-btm-inactive-left-bg.gif +0 -0
  175. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-btm-inactive-right-bg.gif +0 -0
  176. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-btm-left-bg.gif +0 -0
  177. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-btm-right-bg.gif +0 -0
  178. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-close.gif +0 -0
  179. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-strip-bg.gif +0 -0
  180. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-strip-bg.png +0 -0
  181. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-strip-btm-bg.gif +0 -0
  182. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tabs-sprite.gif +0 -0
  183. data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/bg-menu.png +0 -0
  184. data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/bg.gif +0 -0
  185. data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/btn-arrow-light.gif +0 -0
  186. data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/btn-arrow.gif +0 -0
  187. data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/btn-over-bg.gif +0 -0
  188. data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/gray-bg.gif +0 -0
  189. data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/tb-bg.gif +0 -0
  190. data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/tb-btn-sprite.gif +0 -0
  191. data/lipsiadmin_generators/backend/templates/images/ext/slate/tree/arrows.gif +0 -0
  192. data/lipsiadmin_generators/backend/templates/images/ext/slate/window/icon-error.gif +0 -0
  193. data/lipsiadmin_generators/backend/templates/images/ext/slate/window/icon-info.gif +0 -0
  194. data/lipsiadmin_generators/backend/templates/images/ext/slate/window/icon-question.gif +0 -0
  195. data/lipsiadmin_generators/backend/templates/images/ext/slate/window/icon-warning.gif +0 -0
  196. data/lipsiadmin_generators/backend/templates/images/ext/slate/window/left-corners.png +0 -0
  197. data/lipsiadmin_generators/backend/templates/images/ext/slate/window/left-right.png +0 -0
  198. data/lipsiadmin_generators/backend/templates/images/ext/slate/window/right-corners.png +0 -0
  199. data/lipsiadmin_generators/backend/templates/images/ext/slate/window/top-bottom.png +0 -0
  200. data/lipsiadmin_generators/backend/templates/stylesheets/backend-slate.css +0 -105
  201. data/lipsiadmin_generators/backend/templates/stylesheets/ext-slate.css +0 -241
@@ -2,6 +2,7 @@ class PdfGenerator < Rails::Generator::NamedBase
2
2
  def initialize(runtime_args, runtime_options = {})
3
3
  runtime_args = ["pdf"].concat(runtime_args) # Skip usage
4
4
  super
5
+ usage if runtime_args.size == 1
5
6
  end
6
7
 
7
8
  def manifest
@@ -11,10 +12,6 @@ class PdfGenerator < Rails::Generator::NamedBase
11
12
 
12
13
  # Layout and Views
13
14
  m.directory "app/views/pdf"
14
- m.directory "app/views/layouts"
15
-
16
- # Layout
17
- m.template 'layout.html.erb', 'app/views/layouts/print.html.erb'
18
15
 
19
16
  # View template for each action.
20
17
  actions.each do |action|
@@ -1,7 +1,12 @@
1
- -content_for(:header) do
2
- Header Here!
3
-
4
- Content Here!
1
+ %html
2
+ %head
3
+ %meta{'http-equiv' => 'Content-Type', :content => 'text/html', :charset=>"utf-8"}
4
+ =stylesheet_link_tag "standard", "print"
5
+ %body
6
+ -pdf_header do
7
+ My Header
5
8
 
6
- -content_for(:footer) do
7
- Footer Here!
9
+ -pdf_footer do
10
+ My Footer
11
+
12
+ My Content
@@ -4,6 +4,8 @@ class StateSessionGenerator < Rails::Generator::Base
4
4
  def manifest
5
5
  record do |m|
6
6
  # Controller class, functional test, helper, and views.
7
+ m.directory 'app/controllers/backend'
8
+ m.directory 'test/functional/backend'
7
9
  m.template 'controller.rb', 'app/controllers/backend/state_sessions_controller.rb'
8
10
  m.template 'functional_test.rb', 'test/functional/backend/state_sessions_controller_test.rb'
9
11
 
@@ -5,9 +5,13 @@
5
5
  Ext.util.Format.eurMoney = function(v){
6
6
  v = (Math.round((v-0)*100))/100;
7
7
  v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) ? v + "0" : v);
8
- return "€" + v ;
8
+ return v + " €" ;
9
9
  };
10
10
 
11
+ Ext.util.Format.percentage = function(v, p, record){
12
+ return (v + ' %')
13
+ }
14
+
11
15
  Ext.util.Format.boolRenderer = function(v, p, record){
12
16
  p.css += ' x-grid3-check-col-td';
13
17
  return '<div class="x-grid3-check-col'+(v?'-on':'')+' x-grid3-cc-'+this.id+'">&#160;</div>';
@@ -16,12 +20,6 @@ Ext.util.Format.boolRenderer = function(v, p, record){
16
20
  // Tree DropConfig to allow Drop on Leaf
17
21
  var treeDropConfig = { getDropPoint : function(e, n, dd){ var tn = n.node; if(tn.isRoot){ return tn.allowChildren !== false ? "append" : false; } var dragEl = n.ddel; var t = Ext.lib.Dom.getY(dragEl), b = t + dragEl.offsetHeight; var y = Ext.lib.Event.getPageY(e); var noAppend = tn.allowChildren === false; if(this.appendOnly || tn.parentNode.allowChildren === false){ return noAppend ? false : "append"; } var noBelow = false; if(!this.allowParentInsert){ noBelow = tn.hasChildNodes() && tn.isExpanded(); } var q = (b - t) / (noAppend ? 2 : 3); if(y >= t && y < (t + q)){ return "above"; }else if(!noBelow && (noAppend || y >= b-q && y <= b)){ return "below"; }else{ return "append"; } }, completeDrop : function(de){ var ns = de.dropNode, p = de.point, t = de.target; if(!Ext.isArray(ns)){ ns = [ns]; } var n; for(var i = 0, len = ns.length; i < len; i++){ n = ns[i]; if(p == "above"){ t.parentNode.insertBefore(n, t); }else if(p == "below"){ t.parentNode.insertBefore(n, t.nextSibling); }else{ t.leaf = false; t.appendChild(n); } } n.ui.focus(); if(this.tree.hlDrop){ n.ui.highlight(); } t.ui.endDrop(); this.tree.fireEvent("nodedrop", de); } };
18
22
 
19
- // Fix for Prototype Adapter
20
- Ext.lib.Event.getTarget = function(e){
21
- var ee = e.browserEvent || e;
22
- return ee.target ? Event.element(ee) : null;
23
- };
24
-
25
23
  // CheckBox column
26
24
  Ext.grid.CheckColumn = function(config){
27
25
  Ext.apply(this, config);
@@ -110,7 +108,7 @@ Ext.form.DateTimeField = Ext.extend(Ext.form.Field, {
110
108
  /**
111
109
  * @cfg {Object} dateConfig Config for DateField constructor.
112
110
  */
113
- ,allowBlank: false
111
+ ,allowBlank: true
114
112
  /**
115
113
  * @cfg {Object} true to hide the time, default false.
116
114
  */
@@ -145,7 +143,7 @@ Ext.form.DateTimeField = Ext.extend(Ext.form.Field, {
145
143
  var timeConfig = Ext.apply({}, {
146
144
  id:this.id + '-time'
147
145
  ,format:this.timeFormat || Ext.form.TimeField.prototype.format
148
- ,allowBlank:this.allowBlank
146
+ ,allowBlank:(this.hideTime || this.allowBlank)
149
147
  ,width:this.timeWidth
150
148
  ,selectOnFocus:this.selectOnFocus
151
149
  ,listeners:{
@@ -227,7 +225,7 @@ Ext.form.DateTimeField = Ext.extend(Ext.form.Field, {
227
225
  this.isRendered = true;
228
226
  if (this.el.dom.value){
229
227
  this.setValue(this.el.dom.value);
230
- } else {
228
+ } else if (true === this.emptyToNow) {
231
229
  this.setValue(new Date());
232
230
  this.updateHidden();
233
231
  }
@@ -252,7 +250,7 @@ Ext.form.DateTimeField = Ext.extend(Ext.form.Field, {
252
250
  * private initializes internal dateValue
253
251
  */
254
252
  ,initDateValue:function() {
255
- this.dateValue = this.otherToNow ? new Date() : new Date(1970, 0, 1, 0, 0, 0);
253
+ this.dateValue = this.otherToNow ? new Date() : '';
256
254
  }
257
255
  // }}}
258
256
  // {{{
@@ -458,7 +456,7 @@ Ext.form.DateTimeField = Ext.extend(Ext.form.Field, {
458
456
  * private Sets the value of TimeField
459
457
  */
460
458
  ,setTime:function(date) {
461
- this.tf.setValue(date);
459
+ this.tf.setRawValue(date);
462
460
  } // eo function setTime
463
461
  // }}}
464
462
  // {{{
@@ -497,8 +495,8 @@ Ext.form.DateTimeField = Ext.extend(Ext.form.Field, {
497
495
  */
498
496
  ,setValue:function(val) {
499
497
  if(!val && true === this.emptyToNow) {
500
- this.setValue(new Date());
501
- return;
498
+ this.setValue(new Date());
499
+ return;
502
500
  }
503
501
  else if(!val) {
504
502
  this.setDate('');
@@ -508,15 +506,16 @@ Ext.form.DateTimeField = Ext.extend(Ext.form.Field, {
508
506
  }
509
507
  if ('number' === typeof val) {
510
508
  val = new Date(val);
509
+ } else if('string' === typeof val && this.hiddenFormat) {
510
+ val = Date.parseDate(val, this.hiddenFormat)
511
511
  }
512
512
  val = val ? val : new Date(1970, 0 ,1, 0, 0, 0);
513
513
  var da, time;
514
514
  if(val instanceof Date) {
515
515
  this.setDate(val);
516
- this.setTime(val);
516
+ this.setTime(val.format(this.timeFormat));
517
517
  this.dateValue = new Date(val);
518
- }
519
- else {
518
+ } else {
520
519
  da = val.split(this.dtSeparator);
521
520
  this.setDate(da[0]);
522
521
  if(da[1]) {
@@ -0,0 +1,2 @@
1
+ Ext.util.Format.eurMoney=function(v){v=(Math.round((v-0)*100))/100;v=(v==Math.floor(v))?v+".00":((v*10==Math.floor(v*10))?v+"0":v);return v+" €"};Ext.util.Format.boolRenderer=function(v,p,record){p.css+=" x-grid3-check-col-td";return'<div class="x-grid3-check-col'+(v?"-on":"")+" x-grid3-cc-"+this.id+'">&#160;</div>'};var treeDropConfig={getDropPoint:function(e,n,dd){var tn=n.node;if(tn.isRoot){return tn.allowChildren!==false?"append":false}var dragEl=n.ddel;var t=Ext.lib.Dom.getY(dragEl),b=t+dragEl.offsetHeight;var y=Ext.lib.Event.getPageY(e);var noAppend=tn.allowChildren===false;if(this.appendOnly||tn.parentNode.allowChildren===false){return noAppend?false:"append"}var noBelow=false;if(!this.allowParentInsert){noBelow=tn.hasChildNodes()&&tn.isExpanded()}var q=(b-t)/(noAppend?2:3);if(y>=t&&y<(t+q)){return"above"}else{if(!noBelow&&(noAppend||y>=b-q&&y<=b)){return"below"}else{return"append"}}},completeDrop:function(de){var ns=de.dropNode,p=de.point,t=de.target;if(!Ext.isArray(ns)){ns=[ns]}var n;for(var i=0,len=ns.length;i<len;i++){n=ns[i];if(p=="above"){t.parentNode.insertBefore(n,t)}else{if(p=="below"){t.parentNode.insertBefore(n,t.nextSibling)}else{t.leaf=false;t.appendChild(n)}}}n.ui.focus();if(this.tree.hlDrop){n.ui.highlight()}t.ui.endDrop();this.tree.fireEvent("nodedrop",de)}};Ext.grid.CheckColumn=function(config){Ext.apply(this,config);if(!this.id){this.id=Ext.id()}this.renderer=this.renderer.createDelegate(this)};Ext.grid.CheckColumn.prototype={init:function(grid){this.grid=grid;this.grid.on("render",function(){var view=this.grid.getView();view.mainBody.on("mousedown",this.onMouseDown,this)},this)},onMouseDown:function(e,t){if(t.className&&t.className.indexOf("x-grid3-cc-"+this.id)!=-1){e.stopEvent();var index=this.grid.getView().findRowIndex(t);var record=this.grid.store.getAt(index);var editEvent={grid:this.grid,record:this.grid.store.getAt(index),field:this.dataIndex,value:!record.data[this.dataIndex],originalValue:record.data[this.dataIndex],row:index,column:this.grid.getColumnModel().findColumnIndex(this.dataIndex)};record.set(this.dataIndex,editEvent.value);this.grid.getSelectionModel().selectRow(index);this.grid.fireEvent("afteredit",editEvent)}},renderer:function(v,p,record){p.css+=" x-grid3-check-col-td";return'<div class="x-grid3-check-col'+(v?"-on":"")+" x-grid3-cc-"+this.id+'">&#160;</div>'}};Ext.form.DateTimeField=Ext.extend(Ext.form.Field,{defaultAutoCreate:{tag:"input",type:"hidden"},timeWidth:100,dateWidth:100,dtSeparator:" ",hiddenFormat:"Y-m-d H:i:s",otherToNow:true,dateFormat:"d/m/y",timeFormat:"H:i",allowBlank:true,hideTime:false,initComponent:function(){Ext.form.DateTimeField.superclass.initComponent.call(this);var dateConfig=Ext.apply({},{id:this.id+"-date",format:this.dateFormat||Ext.form.DateField.prototype.format,width:this.dateWidth,allowBlank:this.allowBlank,selectOnFocus:this.selectOnFocus,listeners:{blur:{scope:this,fn:this.onBlur},focus:{scope:this,fn:this.onFocus}}},this.dateConfig);this.df=new Ext.form.DateField(dateConfig);this.df.ownerCt=this;delete (this.dateFormat);var timeConfig=Ext.apply({},{id:this.id+"-time",format:this.timeFormat||Ext.form.TimeField.prototype.format,allowBlank:(this.hideTime||this.allowBlank),width:this.timeWidth,selectOnFocus:this.selectOnFocus,listeners:{blur:{scope:this,fn:this.onBlur},focus:{scope:this,fn:this.onFocus}}},this.timeConfig);this.tf=new Ext.form.TimeField(timeConfig);this.tf.ownerCt=this;delete (this.timeFormat);this.relayEvents(this.df,["focus","specialkey","invalid","valid"]);this.relayEvents(this.tf,["focus","specialkey","invalid","valid"])},onRender:function(ct,position){if(this.isRendered){return}Ext.form.DateTimeField.superclass.onRender.call(this,ct,position);var t;var timeStyle=this.hideTime?"display:none":"";t=Ext.DomHelper.append(ct,{tag:"table",style:"border-collapse:collapse",children:[{tag:"tr",children:[{tag:"td",style:"padding-right:17px",cls:"datetime-date"},{tag:"td",cls:"datetime-time",style:timeStyle}]}]},true);this.tableEl=t;this.wrap=t.wrap();this.wrap.on("mousedown",this.onMouseDown,this,{delay:10});this.df.render(t.child("td.datetime-date"));this.tf.render(t.child("td.datetime-time"));this.df.wrap.setStyle({width:this.dateWidth});this.tf.wrap.setStyle({width:this.timeWidth});if(Ext.isIE&&Ext.isStrict){t.select("input").applyStyles({top:0})}this.on("specialkey",this.onSpecialKey,this);this.df.el.swallowEvent(["keydown","keypress"]);this.tf.el.swallowEvent(["keydown","keypress"]);if("side"===this.msgTarget){var elp=this.el.findParent(".x-form-element",10,true);this.errorIcon=elp.createChild({cls:"x-form-invalid-icon"});this.df.errorIcon=this.errorIcon;this.tf.errorIcon=this.errorIcon}if(!this.el.dom.name){this.el.dom.name=this.hiddenName||this.name||this.id}this.df.el.dom.removeAttribute("name");this.tf.el.dom.removeAttribute("name");this.isRendered=true;if(this.el.dom.value){this.setValue(this.el.dom.value)}else{this.setValue(new Date());this.updateHidden()}},adjustSize:Ext.BoxComponent.prototype.adjustSize,alignErrorIcon:function(){this.errorIcon.alignTo(this.tableEl,"tl-tr",[2,0])},initDateValue:function(){this.dateValue=this.otherToNow?new Date():new Date(1970,0,1,0,0,0)},clearInvalid:function(){this.df.clearInvalid();this.tf.clearInvalid()},beforeDestroy:function(){if(this.isRendered){this.wrap.removeAllListeners();this.wrap.remove();this.tableEl.remove();this.df.destroy();this.tf.destroy()}},disable:function(){if(this.isRendered){this.df.disabled=this.disabled;this.df.onDisable();this.tf.onDisable()}this.disabled=true;this.df.disabled=true;this.tf.disabled=true;this.fireEvent("disable",this);return this},enable:function(){if(this.rendered){this.df.onEnable();this.tf.onEnable()}this.disabled=false;this.df.disabled=false;this.tf.disabled=false;this.fireEvent("enable",this);return this},focus:function(){this.df.focus()},getPositionEl:function(){return this.wrap},getResizeEl:function(){return this.wrap},getValue:function(){return this.dateValue?new Date(this.dateValue):""},isValid:function(){return this.df.isValid()&&this.tf.isValid()},isVisible:function(){return this.df.rendered&&this.df.getActionEl().isVisible()},onBlur:function(f){if(this.wrapClick){f.focus();this.wrapClick=false}this.updateDate();this.updateTime();this.updateHidden();(function(){if(!this.df.hasFocus&&!this.tf.hasFocus){var v=this.getValue();if(String(v)!==String(this.startValue)){this.fireEvent("change",this,v,this.startValue)}this.hasFocus=false;this.fireEvent("blur",this)}}).defer(100,this)},onFocus:function(){if(!this.hasFocus){this.hasFocus=true;this.startValue=this.getValue();this.fireEvent("focus",this)}},onMouseDown:function(e){if(!this.disabled){this.wrapClick="td"===e.target.nodeName.toLowerCase()}},onSpecialKey:function(t,e){var key=e.getKey();if(key===e.TAB){if(t===this.df&&!e.shiftKey){e.stopEvent();this.tf.focus()}if(t===this.tf&&e.shiftKey){e.stopEvent();this.df.focus()}}if(key===e.ENTER){this.updateValue()}},setDate:function(date){this.df.setValue(date)},setTime:function(date){this.tf.setValue(date)},setSize:function(w,h){if(!w){return}if("below"===this.timePosition){this.df.setSize(w,h);this.tf.setSize(w,h);if(Ext.isIE){this.df.el.up("td").setWidth(w);this.tf.el.up("td").setWidth(w)}}else{this.df.setSize(w-this.timeWidth-4,h);this.tf.setSize(this.timeWidth,h);if(Ext.isIE){this.df.el.up("td").setWidth(w-this.timeWidth-4);this.tf.el.up("td").setWidth(this.timeWidth)}}},setValue:function(val){if(!val&&true===this.emptyToNow){this.setValue(new Date());return}else{if(!val){this.setDate("");this.setTime("");this.updateValue();return}}if("number"===typeof val){val=new Date(val)}else{if("string"===typeof val&&this.hiddenFormat){val=Date.parseDate(val,this.hiddenFormat)}}val=val?val:new Date(1970,0,1,0,0,0);var da,time;if(val instanceof Date){this.setDate(val);this.setTime(val);this.dateValue=new Date(val)}else{da=val.split(this.dtSeparator);this.setDate(da[0]);if(da[1]){if(da[2]){da[1]+=da[2]}var hh=da[1].split(":");this.setTime(hh[0]+":"+hh[1])}}},setVisible:function(visible){if(visible){this.df.show();
2
+ this.tf.show()}else{this.df.hide();this.tf.hide()}return this},show:function(){return this.setVisible(true)},hide:function(){return this.setVisible(false)},updateDate:function(){var d=this.df.getValue();if(d){if(!(this.dateValue instanceof Date)){this.initDateValue();if(!this.tf.getValue()){this.setTime(this.dateValue)}}this.dateValue.setMonth(0);this.dateValue.setFullYear(d.getFullYear());this.dateValue.setMonth(d.getMonth());this.dateValue.setDate(d.getDate())}else{this.dateValue="";this.setTime("")}},updateTime:function(){var t=this.tf.getValue();if(t&&!(t instanceof Date)){t=Date.parseDate(t,this.tf.format)}if(t&&!this.df.getValue()){this.initDateValue();this.setDate(this.dateValue)}if(this.dateValue instanceof Date){if(t){this.dateValue.setHours(t.getHours());this.dateValue.setMinutes(t.getMinutes());this.dateValue.setSeconds(t.getSeconds())}else{this.dateValue.setHours(0);this.dateValue.setMinutes(0);this.dateValue.setSeconds(0)}}},updateHidden:function(){if(this.isRendered){var value=this.dateValue instanceof Date?this.dateValue.format(this.hiddenFormat):"";this.el.dom.value=value}},updateValue:function(){this.updateDate();this.updateTime();this.updateHidden();return},validate:function(){return this.df.validate()&&this.tf.validate()},renderer:function(field){var format=field.editor.dateFormat||Ext.form.DateTime.prototype.dateFormat;format+=" "+(field.editor.timeFormat||Ext.form.DateTime.prototype.timeFormat);var renderer=function(val){var retval=Ext.util.Format.date(val,format);return retval};return renderer}});Ext.reg("datetimefield",Ext.form.DateTimeField);Ext.grid.Search=function(config){Ext.apply(this,config);Ext.grid.Search.superclass.constructor.call(this)};Ext.extend(Ext.grid.Search,Ext.util.Observable,{autoFocus:true,searchText:"Search",searchTipText:"Insert a word or press Search",selectAllText:"Select All",position:"top",iconCls:"check",checkIndexes:"all",disableIndexes:[],dateFormat:undefined,showSelectAll:true,menuStyle:"checkbox",minCharsTipText:"Insert at least {0} characters",mode:"remote",width:200,xtype:"gridsearch",paramNames:{fields:"fields",query:"query"},shortcutKey:"r",shortcutModifier:"alt",align:"right",minLength:3,init:function(grid){this.grid=grid;if("string"===typeof this.toolbarContainer){this.toolbarContainer=Ext.getCmp(this.toolbarContainer)}grid.onRender=grid.onRender.createSequence(this.onRender,this);grid.reconfigure=grid.reconfigure.createSequence(this.reconfigure,this)},onRender:function(){var panel=this.toolbarContainer||this.grid;var tb="bottom"===this.position?panel.bottomToolbar:panel.topToolbar;this.menu=new Ext.menu.Menu();if("right"===this.align){tb.addFill()}else{if(0<tb.items.getCount()){tb.addSeparator()}}tb.add({text:this.searchText,menu:this.menu});this.field=new Ext.form.TwinTriggerField({width:this.width,selectOnFocus:undefined===this.selectOnFocus?true:this.selectOnFocus,trigger1Class:"x-form-clear-trigger",trigger2Class:this.minChars?"x-hidden":"x-form-search-trigger",onTrigger1Click:this.minChars?Ext.emptyFn:this.onTriggerClear.createDelegate(this),onTrigger2Click:this.onTriggerSearch.createDelegate(this),minLength:this.minLength});this.field.on("render",function(){this.field.el.dom.qtip=this.minChars?String.format(this.minCharsTipText,this.minChars):this.searchTipText;if(this.minChars){this.field.el.on({scope:this,buffer:300,keyup:this.onKeyUp})}var map=new Ext.KeyMap(this.field.el,[{key:Ext.EventObject.ENTER,scope:this,fn:this.onTriggerSearch},{key:Ext.EventObject.ESC,scope:this,fn:this.onTriggerClear}]);map.stopEvent=true},this,{single:true});tb.add(this.field);this.reconfigure();if(this.shortcutKey&&this.shortcutModifier){var shortcutEl=this.grid.getEl();var shortcutCfg=[{key:this.shortcutKey,scope:this,stopEvent:true,fn:function(){this.field.focus()}}];shortcutCfg[0][this.shortcutModifier]=true;this.keymap=new Ext.KeyMap(shortcutEl,shortcutCfg)}if(true===this.autoFocus){this.grid.store.on({scope:this,load:function(){this.field.focus()}})}},onKeyUp:function(){var length=this.field.getValue().toString().length;if(0===length||this.minChars<=length){this.onTriggerSearch()}},onTriggerClear:function(){if(this.field.getValue()){this.field.setValue("");this.field.focus();this.onTriggerSearch()}},onTriggerSearch:function(){if(!this.field.isValid()){return}var val=this.field.getValue();var store=this.grid.store;if("local"===this.mode){store.clearFilter();if(val){store.filterBy(function(r){var retval=false;this.menu.items.each(function(item){if(!item.checked||retval){return}var rv=r.get(item.dataIndex);rv=rv instanceof Date?rv.format(this.dateFormat||r.fields.get(item.dataIndex).dateFormat):rv;var re=new RegExp(val,"gi");retval=re.test(rv)},this);if(retval){return true}return retval},this)}else{}}else{if(store.lastOptions&&store.lastOptions.params){store.lastOptions.params[store.paramNames.start]=0}var fields=[];this.menu.items.each(function(item){if(item.checked&&item.dataIndex){fields.push(item.dataIndex)}});delete (store.baseParams[this.paramNames.fields]);delete (store.baseParams[this.paramNames.query]);if(store.lastOptions&&store.lastOptions.params){delete (store.lastOptions.params[this.paramNames.fields]);delete (store.lastOptions.params[this.paramNames.query])}if(fields.length){store.baseParams[this.paramNames.fields]=fields.compact().join();store.baseParams[this.paramNames.query]=val}store.reload()}},setDisabled:function(){this.field.setDisabled.apply(this.field,arguments)},enable:function(){this.setDisabled(false)},disable:function(){this.setDisabled(true)},reconfigure:function(){var menu=this.menu;menu.removeAll();if(this.showSelectAll&&"radio"!==this.menuStyle){menu.add(new Ext.menu.CheckItem({text:this.selectAllText,checked:!(this.checkIndexes instanceof Array),hideOnClick:false,handler:function(item){var checked=!item.checked;item.parentMenu.items.each(function(i){if(item!==i&&i.setChecked&&!i.disabled){i.setChecked(checked)}})}}),"-")}var cm=this.grid.colModel;var group=undefined;if("radio"===this.menuStyle){group="g"+(new Date).getTime()}Ext.each(cm.config,function(config){var disable=false;if(config.header&&config.dataIndex&&config.sortable){Ext.each(this.disableIndexes,function(item){disable=disable?disable:item===config.dataIndex});if(!disable){menu.add(new Ext.menu.CheckItem({text:config.header,hideOnClick:false,group:group,checked:"all"===this.checkIndexes,dataIndex:config.dataIndex}))}}},this);if(this.checkIndexes instanceof Array){Ext.each(this.checkIndexes,function(di){var item=menu.items.find(function(itm){return itm.dataIndex===di});if(item){item.setChecked(true,true)}},this)}if(this.readonlyIndexes instanceof Array){Ext.each(this.readonlyIndexes,function(di){var item=menu.items.find(function(itm){return itm.dataIndex===di});if(item){item.disable()}},this)}}});Ext.state.DataBaseProvider=function(config){Ext.state.DataBaseProvider.superclass.constructor.call(this);this.path="/backend/state_sessions";Ext.apply(this,config);this.state=this.readCookies()};Ext.extend(Ext.state.DataBaseProvider,Ext.state.Provider,{set:function(name,value){if(typeof value=="undefined"||value===null){this.clear(name);return}this.setCookie(name,value);Ext.state.DataBaseProvider.superclass.set.call(this,name,value)},clear:function(name){this.clearCookie(name);Ext.state.DataBaseProvider.superclass.clear.call(this,name)},readCookies:function(){var cookies={};var values=[];new Ajax.Request(this.path,{method:"GET",asynchronous:false,onSuccess:function(response,request){values=Ext.decode(response.responseText)}});values.each(function(f){if(f.state_session&&f.state_session.component&&f.state_session.component.substring(0,3)=="ys-"){cookies[f.state_session.component.substr(3)]=this.decodeValue(f.state_session.data)}},this);return cookies},setCookie:function(name,value){Ext.Ajax.request({url:this.path,method:"POST",params:{id:"ys-"+name,data:this.encodeValue(value)}})},clearCookie:function(name){Ext.Ajax.request({url:this.path+"/ys-"+name,method:"DELETE"})}});
Binary file
@@ -1,52 +1,298 @@
1
- // For compile javac -cp pd4ml.jar Pd4Ruby.java
1
+ /* Pd4Ruby
2
+ * Created for PDF::PD4ML Ruby library. This is a wrapper for the commercial
3
+ * library PD4ML which converts HTML documents to PDF
4
+ *
5
+ * Author: Nilesh Chaudhari
6
+ *
7
+ * Released under MIT license
8
+ *
9
+ * For compile javac -cp pd4ml.jar Pd4Ruby.java
10
+ */
11
+
2
12
  import java.awt.Dimension;
3
13
  import java.awt.Insets;
4
14
  import java.lang.reflect.Field;
5
15
  import java.net.URL;
6
-
16
+ import java.util.StringTokenizer;
17
+
7
18
  import org.zefer.pd4ml.PD4Constants;
8
19
  import org.zefer.pd4ml.PD4ML;
9
-
20
+ import org.zefer.pd4ml.PD4PageMark;
21
+
10
22
  public class Pd4Ruby {
11
-
23
+
24
+ public final static String USAGE = "Usage: java -Xmx512m Pd4Ruby --url <url> --file <file> \\\n" +
25
+ " [--width <html_width>] \\\n" +
26
+ " [--pagesize <A1-A10|ISOB0-ISOB5|LEGAL|LETTER|LEDGER|NOTE|TABLOID>] \\\n" +
27
+ " [--permissions <integer> --password <password>] \\\n" +
28
+ " [--bookmarks <HEADINGS|ANCHORS>] \\\n" +
29
+ " [--orientation <PORTRAIT|LANDSCAPE>] \\\n" +
30
+ " [--insets <T,L,B,R,><mm|pt>] \\\n" +
31
+ " [--ttf <ttf_fonts_dir>] \\\n" +
32
+ " [--header '<html_text>'] \\\n" +
33
+ " [--footer '<html_text>'] \\\n" +
34
+ " [--debug]";
35
+
12
36
  public static void main(String[] args) throws Exception {
13
-
14
- if ( args.length < 2 ) {
15
- System.out.println( "Usage: java -Xmx512m Pd4Ruby <url> <htmlWidth> <pageFormat> <landescape> [TTFfontsDir]" );
37
+
38
+ String url = null;
39
+ String file = null;
40
+ int debug = 0;
41
+ int width = 800;
42
+ String pagesize = "A4";
43
+ int permissions = 65532; // all permissions off by default
44
+ String bookmarks = "HEADINGS";
45
+ String orientation = "PORTRAIT";
46
+ String insets = null;
47
+ String ttf = null;
48
+ String password = null;
49
+ String header = null;
50
+ String footer = null;
51
+
52
+ boolean formatSet = false;
53
+
54
+ for( int i = 0; i < args.length; i++ ) {
55
+
56
+ if ( "--url".equals( args[i] ) ) {
57
+ ++i;
58
+ if (( i == args.length ) || ( args[i].startsWith("--") )) {
59
+ System.out.println("invalid parameter: missing url");
60
+ System.out.println( USAGE );
61
+ return;
62
+ }
63
+ url = args[i];
64
+ continue;
65
+ }
66
+
67
+ if ( "--file".equals( args[i] ) ) {
68
+ ++i;
69
+ if (( i == args.length ) || ( args[i].startsWith("--") )) {
70
+ System.out.println("invalid parameter: missing file");
71
+ System.out.println( USAGE );
72
+ return;
73
+ }
74
+ file = args[i];
75
+ continue;
76
+ }
77
+
78
+ if ( "--permissions".equals( args[i] ) ) {
79
+ ++i;
80
+ if ( i == args.length ) {
81
+ System.out.println("invalid parameter: missing permissions number (a sum of single permission codes)");
82
+ System.out.println( USAGE );
83
+ return;
84
+ }
85
+ permissions = Integer.parseInt(args[i]);
86
+ continue;
87
+ }
88
+
89
+ if ( "--password".equals( args[i] ) ) {
90
+ ++i;
91
+ if ( i == args.length ) {
92
+ System.out.println("invalid parameter: missing password");
93
+ System.out.println( USAGE );
94
+ return;
95
+ }
96
+ password = args[i];
97
+ continue;
98
+ }
99
+
100
+ if ( "--bookmarks".equals( args[i] ) ) {
101
+ ++i;
102
+ if ( i == args.length ) {
103
+ System.out.println("invalid parameter: missing bookmark type (HEADINGS or ANCHORS)");
104
+ System.out.println( USAGE );
105
+ return;
106
+ }
107
+ bookmarks = args[i];
108
+ continue;
109
+ }
110
+
111
+ if ( "--orientation".equals( args[i] ) ) {
112
+ ++i;
113
+ if ( i == args.length ) {
114
+ System.out.println("invalid parameter: missing orientation type (PORTRAIT or LANDSCAPE)");
115
+ System.out.println( USAGE );
116
+ return;
117
+ }
118
+ orientation = args[i];
119
+ continue;
120
+ }
121
+
122
+ if ( "--pagesize".equals( args[i] ) ) {
123
+ ++i;
124
+ if ( i == args.length ) {
125
+ System.out.println("invalid parameter: missing page size");
126
+ System.out.println( USAGE );
127
+ return;
128
+ }
129
+ pagesize = args[i];
130
+ continue;
131
+ }
132
+
133
+ if ( "--insets".equals( args[i] ) ) {
134
+ ++i;
135
+ if ( i == args.length ) {
136
+ System.out.println("invalid parameter: missing insets (for exampe: --insets 5,10,5,5mm)");
137
+ System.out.println( USAGE );
138
+ return;
139
+ }
140
+ insets = args[i];
141
+ continue;
142
+ }
143
+
144
+ if ( "--ttf".equals( args[i] ) ) {
145
+ ++i;
146
+ if ( i == args.length ) {
147
+ System.out.println("invalid parameter: missing TTF fonts directory");
148
+ System.out.println( USAGE );
149
+ return;
150
+ }
151
+ ttf = args[i];
152
+ continue;
153
+ }
154
+
155
+ if ( "--header".equals( args[i] ) ) {
156
+ ++i;
157
+ if ( i == args.length ) {
158
+ System.out.println("invalid parameter: missing header text");
159
+ System.out.println( USAGE );
160
+ return;
161
+ }
162
+ header = args[i];
163
+ continue;
164
+ }
165
+
166
+ if ( "--footer".equals( args[i] ) ) {
167
+ ++i;
168
+ if ( i == args.length ) {
169
+ System.out.println("invalid parameter: missing footer text");
170
+ System.out.println( USAGE );
171
+ return;
172
+ }
173
+ footer = args[i];
174
+ continue;
175
+ }
176
+
177
+ if ( "--debug".equals( args[i] ) ) {
178
+ debug = 1;
179
+ continue;
180
+ }
181
+
182
+ if ( "--width".equals( args[i] ) ) {
183
+ ++i;
184
+ if ( i == args.length ) {
185
+ System.out.println("invalid width: missing HTML width");
186
+ System.out.println( USAGE );
187
+ return;
188
+ }
189
+ width = Integer.parseInt(args[i]);
190
+ continue;
191
+ }
192
+
193
+ if ( args[i].startsWith("--") ) {
194
+ System.out.println("unknown parameter: " + args[i] );
195
+ System.out.println( USAGE );
196
+ return;
197
+ }
198
+
199
+ System.out.println("unexpected parameter: " + args[i]);
200
+ System.out.println( USAGE );
201
+ return;
16
202
  }
17
-
203
+
204
+ if (( url == null ) && ( file == null)) {
205
+ System.out.println("source is missing. Specify at least a url or a file.");
206
+ System.out.println( USAGE );
207
+ return;
208
+ }
209
+
18
210
  Pd4Ruby converter = new Pd4Ruby();
19
- converter.generatePDF( args[0], args[1], args[2], args[3], args.length > 4 ? args[4] : null );
211
+ converter.generatePDF( url, file, width, pagesize, permissions, password, bookmarks, orientation, insets, ttf, header, footer, debug );
20
212
  }
21
-
22
- private void generatePDF(String inputUrl, String htmlWidth, String pageFormat, String landescape, String fontsDir)
23
- throws Exception {
24
-
213
+
214
+ private void generatePDF(String inputUrl, String inputFile, int htmlWidth, String pageFormat, int permissions, String password, String bookmarks, String orientation, String insets, String fontsDir, String headerBody, String footerBody, int debug)
215
+ throws Exception {
216
+
25
217
  PD4ML pd4ml = new PD4ML();
26
- pd4ml.setPageInsets(new Insets(15, 20, 10, 20));
27
-
28
- if (htmlWidth != null) {
29
- pd4ml.setHtmlWidth(Integer.parseInt(htmlWidth));
218
+
219
+ if ( insets != null ) {
220
+ StringTokenizer st = new StringTokenizer( insets, ",");
221
+ try {
222
+ int top = Integer.parseInt(st.nextToken());
223
+ int left = Integer.parseInt(st.nextToken());
224
+ int bottom = Integer.parseInt(st.nextToken());
225
+ int right = Integer.parseInt(st.nextToken());
226
+ String units = st.nextToken();
227
+ Insets ins = new Insets(top, left, bottom, right);
228
+ if ("mm".equalsIgnoreCase(units)) {
229
+ pd4ml.setPageInsetsMM(ins);
230
+ } else {
231
+ pd4ml.setPageInsets(ins);
232
+ }
233
+ } catch (Exception e) {
234
+ throw new Exception(
235
+ "Invalid page insets (top, left, bottom, right, units): "
236
+ + insets );
237
+ }
30
238
  }
31
-
239
+
240
+ pd4ml.setHtmlWidth(htmlWidth);
241
+ pd4ml.setAuthorName("LipsiaSoft s.r.l.");
242
+
32
243
  Class c = PD4Constants.class;
33
244
  Field f = c.getField( pageFormat );
34
245
  Dimension d = (Dimension)f.get( pd4ml );
35
-
36
- if (landescape.equals("true")){
37
- d = pd4ml.changePageOrientation(d);
246
+
247
+ if ("PORTRAIT".equalsIgnoreCase(orientation)) {
248
+ pd4ml.setPageSize(d);
249
+ } else {
250
+ pd4ml.setPageSize( pd4ml.changePageOrientation( d ) );
38
251
  }
39
-
40
- pd4ml.setPageSize(d);
41
-
42
- pd4ml.setAuthorName("LipsiaSoft s.r.l.");
43
-
252
+
253
+ if ( permissions != -1 ) {
254
+ if ( password != null ) {
255
+ pd4ml.setPermissions(password, permissions, true);
256
+ } else {
257
+ pd4ml.setPermissions("empty", permissions, true);
258
+ }
259
+ }
260
+
261
+ if ( bookmarks != null ) {
262
+ if ( "ANCHORS".equalsIgnoreCase(bookmarks) ) {
263
+ pd4ml.generateOutlines(false);
264
+ } else if ( "HEADINGS".equalsIgnoreCase(bookmarks) ) {
265
+ pd4ml.generateOutlines(true);
266
+ }
267
+ }
268
+
44
269
  if ( fontsDir != null && fontsDir.length() > 0 ) {
45
270
  pd4ml.useTTF( fontsDir, true );
46
- }
47
-
48
- java.io.StringReader reader = new java.io.StringReader(inputUrl);
49
-
50
- pd4ml.render(reader, System.out);
271
+ }
272
+
273
+ if ( headerBody != null && headerBody.length() > 0 ) {
274
+ PD4PageMark header = new PD4PageMark();
275
+ header.setAreaHeight( -1 ); // autocompute
276
+ header.setHtmlTemplate( headerBody ); // autocompute
277
+ pd4ml.setPageHeader( header );
278
+ }
279
+
280
+ if ( footerBody != null && footerBody.length() > 0 ) {
281
+ PD4PageMark footer = new PD4PageMark();
282
+ footer.setAreaHeight( -1 ); // autocompute
283
+ footer.setHtmlTemplate( headerBody ); // autocompute
284
+ pd4ml.setPageFooter( footer );
285
+ }
286
+
287
+ if ( debug != 0 ) {
288
+ pd4ml.enableDebugInfo();
289
+ }
290
+
291
+ if (inputFile != null) {
292
+ pd4ml.render(("file:" + inputFile), System.out);
293
+ } else if (inputUrl != null) {
294
+ pd4ml.render(new URL(inputUrl), System.out);
295
+ }
51
296
  }
52
297
  }
298
+