| 第45行: | 
第45行: | 
|   |      end  |   |      end  | 
|   |      return results  |   |      return results  | 
|   | + | end  | 
|   | + |  | 
|   | + | function p.query_reversed_inherited_property(name, anchor_property, query_property)  | 
|   | + |     return p.query_inherited_property(query_property, anchor_property, parent_list, {name})  | 
|   | end  |   | end  | 
|   |  |   |  | 
| 第57行: | 
第61行: | 
|   |      for k, v in ipairs(list) do  |   |      for k, v in ipairs(list) do  | 
|   |          ul:tag("li"):wikitext("[["..v.."]]")  |   |          ul:tag("li"):wikitext("[["..v.."]]")  | 
|   | + |     end  | 
|   | + | end  | 
|   | + |  | 
|   | + | function _split_or_empty(value)  | 
|   | + |     if value and #value > 0 then  | 
|   | + |         return mw.text.split(value, ",")  | 
|   | + |     else  | 
|   | + |         return {}  | 
|   |      end  |   |      end  | 
|   | end  |   | end  | 
| 第62行: | 
第74行: | 
|   | function p.inherited_lists(frame)  |   | function p.inherited_lists(frame)  | 
|   |      local name = frame.args.name  |   |      local name = frame.args.name  | 
| − |      local parents = (frame.args.parents and #frame.args.parents > 0) and mw.text.split(frame.args.parents, ",") or {}  | + |      local parents = _split_or_empty(frame.args.parents)  | 
|   |      local parent_property = frame.args.parent_property  |   |      local parent_property = frame.args.parent_property  | 
|   |      local parent_title = frame.args.parent_title  |   |      local parent_title = frame.args.parent_title  | 
|   |      local anchor_property = frame.args.anchor_property  |   |      local anchor_property = frame.args.anchor_property  | 
|   |      local properties = mw.text.split(frame.args.properties, ",")  |   |      local properties = mw.text.split(frame.args.properties, ",")  | 
|   | + |     local reversed_properties = mw.text.split(frame.args.reversed_properties, ",")  | 
|   |      local children_title = frame.args.children_title  |   |      local children_title = frame.args.children_title  | 
|   |  |   |  | 
| 第79行: | 
第92行: | 
|   |      for i, prop in ipairs(properties) do  |   |      for i, prop in ipairs(properties) do  | 
|   |          local title = frame.args[prop.."_title"]  |   |          local title = frame.args[prop.."_title"]  | 
| − |          local values_str = frame.args[prop.."_values"]  | + |          local values = _split_or_empty(frame.args[prop.."_values"])  | 
| − |         local values = (values_str and #values_str > 0) and mw.text.split(values_str, ",") or {}
  |   | 
|   |          local values_set = _table_to_keys(values)  |   |          local values_set = _table_to_keys(values)  | 
|   |          local inherited_values = p.query_inherited_property(anchor_property, prop, parents)  |   |          local inherited_values = p.query_inherited_property(anchor_property, prop, parents)  | 
| − |         mw.logObject(inherited_values)
  |   | 
|   |          local final_values = _merge_keys(values_set, inherited_values)  |   |          local final_values = _merge_keys(values_set, inherited_values)  | 
|   | + |         local final_list = _keys_to_table(final_values)  | 
|   | + |         _create_list(root, title, final_list)  | 
|   | + |         for i, k in ipairs(final_list) do  | 
|   | + |             mw.smw.set({[prop]=k})  | 
|   | + |         end  | 
|   | + |     end  | 
|   | + |  | 
|   | + |     for i, prop in ipairs(reversed_properties) do  | 
|   | + |         local title = frame.args[prop.."_reversed"]  | 
|   | + |         local rev_prop = frame.args[prop.."_property"]  | 
|   | + |         local final_values = p.query_reversed_inherited_property(name, anchor_property, rev_prop)  | 
|   |          local final_list = _keys_to_table(final_values)  |   |          local final_list = _keys_to_table(final_values)  | 
|   |          _create_list(root, title, final_list)  |   |          _create_list(root, title, final_list)  |