Changeset 1147 for trunk/lib/parser
- Timestamp:
- 2008-09-15 13:51:17 (4 months ago)
- Files:
-
- trunk/lib/parser/lib/rules/zena.rb (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/parser/lib/rules/zena.rb
r1138 r1147 278 278 elsif @params[:attr] 279 279 attribute_method = node_attribute(@params[:attr], :else=>@params[:else], :default=>@params[:default]) 280 elsif p = @params[:param] 281 return "<%= params[#{p.to_sym.inspect}] %>" 280 282 elsif @params[:date] 281 283 # date can be any attribute v_created_at or updated_at etc. … … 482 484 483 485 context_bak = @context.dup # avoid side effects when rendering the same block 484 template = expand_block(self, :block=>self, :list=>false, :saved_template=>true, :ignore =>['form']) 486 ignore_list = @method == 'block' ? ['form'] : [] # do not show the form in the normal template of a block 487 template = expand_block(self, :block=>self, :list=>false, :saved_template=>true, :ignore => ignore_list) 485 488 @context = context_bak 486 489 @result = '' … … 523 526 end 524 527 return parser_error("cannot use 's' as key (used by start_node)") if @params[:key] == 's' 525 out "<%= form_remote_tag(:url => zafu_node_path(#{node_id}), :method => :get, :html => {:id => \"#{dom_id}_f\"}) %><div class='hidden'><input type='hidden' name='t_url' value='#{block.template_url}'/><input type='hidden' name='dom_id' value='#{block.erb_dom_id}'/>#{start_node_ input}</div><div class='wrapper'>"528 out "<%= form_remote_tag(:url => zafu_node_path(#{node_id}), :method => :get, :html => {:id => \"#{dom_id}_f\"}) %><div class='hidden'><input type='hidden' name='t_url' value='#{block.template_url}'/><input type='hidden' name='dom_id' value='#{block.erb_dom_id}'/>#{start_node_s_param(:input)}</div><div class='wrapper'>" 526 529 if @blocks == [] 527 530 out "<input type='text' name='#{@params[:key] || 'f'}' value='<%= params[#{(@params[:key] || 'f').to_sym.inspect}] %>'/>" … … 1237 1240 next if [:hover, :change, :done].include?(k) 1238 1241 value, static = parse_attributes_in_value(v, :erb => false, :skip_node_attributes => true) 1239 url_params << "node[#{k}]=#{CGI.escape(value)}" 1242 key = change == 'params' ? "params[#{k}]" : "node[#{k}]" 1243 url_params << "#{key}=#{CGI.escape(value)}" 1240 1244 end 1241 1245 return parser_error("missing parameters to set values") if url_params == [] 1242 1246 end 1243 1247 1244 url_params << "change= dropped" if change == 'dropped'1248 url_params << "change=#{change}" if change == 'receiver' 1245 1249 url_params << "t_url=#{CGI.escape(template_url)}" 1246 1250 url_params << "dom_id=#{erb_dom_id}" 1251 url_params << start_node_s_param(:erb) 1247 1252 url_params << "done=#{CGI.escape(@params[:done])}" if @params[:done] 1248 1253 … … 2174 2179 def node(klass = self.node_class) 2175 2180 if klass == self.node_class 2176 @context[:saved_template]? "@#{base_class.to_s.underscore}" : (@context[:node] || '@node')2181 (@context[:saved_template] && @context[:main_node]) ? "@#{base_class.to_s.underscore}" : (@context[:node] || '@node') 2177 2182 elsif klass == Node 2178 2183 @context[:previous_node] || '@node' … … 2370 2375 # DOM id for the current context 2371 2376 def dom_id(suffix='') 2372 return "\#{dom_id(#{node})}" if @context && @context[:saved_template]2377 return "\#{dom_id(#{node})}" if @context && (@context[:saved_template] && @context[:main_node]) 2373 2378 if @context && scope_node = @context[:scope_node] 2374 2379 res = "#{dom_prefix}_\#{#{scope_node}.zip}" … … 2395 2400 2396 2401 def erb_dom_id(suffix='') 2397 return "<%= dom_id(#{node}) %>" if @context && @context[:saved_template]2402 return "<%= dom_id(#{node}) %>" if @context && (@context[:saved_template] && @context[:main_node]) 2398 2403 if @context && scope_node = @context[:scope_node] 2399 2404 res = "#{dom_prefix}_<%= #{scope_node}.zip %>" … … 2444 2449 # use our own scope 2445 2450 def clear_dom_scope 2446 @context.delete(:dom_prefix) # should not propagate2447 2451 @context.delete(:make_form) # should not propagate 2448 @context.delete(: saved_template)# should not propagate2452 @context.delete(:main_node) # should not propagate 2449 2453 end 2450 2454 … … 2452 2456 def new_dom_scope 2453 2457 clear_dom_scope 2458 @context.delete(:saved_template) # should not propagate on fresh template 2459 @context.delete(:dom_prefix) # should not propagate on fresh template 2460 @context[:main_node] = true # the current context will be rendered with a fresh '@node' 2454 2461 @context[:dom_prefix] = self.dom_prefix 2455 2462 end … … 2847 2854 url_params << "link_id=\#{#{node}.link_id}" if @context[:need_link_id] && node_kind_of?(Node) 2848 2855 url_params << "node[v_status]=#{Zena::Status[:pub]}" if @params[:publish] 2849 url_params << start_node_ input(false)2856 url_params << start_node_s_param(:string) 2850 2857 2851 2858 res = '' … … 3083 3090 return '' if attribute == 'parent_id' # set with 'r_form' 3084 3091 3085 if @context[:in_add] 3086 value = '' 3087 else 3088 value = attribute ? "<%= #{node_attribute(attribute)} %>" : "" 3092 if @blocks == [] || @blocks == [''] 3093 if @context[:in_add] 3094 value = '' 3095 else 3096 value = attribute ? "<%= #{node_attribute(attribute)} %>" : "" 3097 end 3098 else 3099 value = expand_with 3089 3100 end 3090 3101 html_id = @context[:dom_prefix] ? " id='#{erb_dom_id}_#{attribute}'" : '' … … 3118 3129 end 3119 3130 3120 def start_node_ input(erb = true)3121 if erb3131 def start_node_s_param(type = :input) 3132 if type == :input 3122 3133 "<input type='hidden' name='s' value='<%= params[:s] || @node[:zip] %>'/>" 3134 elsif type == :erb 3135 "s=<%= params[:s] || @node[:zip] %>" 3123 3136 else 3124 3137 "s=\#{params[:s] || @node[:zip]}"
