%
# WontoMedia - a wontology web application
# Copyright (C) 2011 - Glen E. Ivey
# www.wontology.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License version
# 3 as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program in the file COPYING and/or LICENSE. If not,
# see "http://www.gnu.org/licenses/".
%>
<%
require Rails.root.join( 'lib', 'helpers', 'item_helper')
@title_text = h( filter_parenthetical( @item.title ) )
# initialize array to define "Glossary Help" box of links:
@glossary_help_entries = [
[ 'Name', 'Help:GlossaryAtoO#anchor_Name' ],
[ 'Title', 'Help:GlossaryPtoZ#anchor_Title' ],
[ 'Description', 'Help:GlossaryAtoO#anchor_Description' ],
[ 'Item', 'Help:GlossaryAtoO#anchor_Item' ]
]
%>
<% # question-icon for title/name/desc pop-up help
unless @popup_flag %>
<%= popup_help_icon "Help, item content", "Help:Popup/HeaderItem" %>
<% end %>
<% # populate top (title/name/desc) section of page
%>
<%= text_with_tooltip h( @item.title ),
' Title of this Item ', 'item_title' %>
<%= text_with_tooltip h( @item.name ),
' Name of this Item ', 'item_name' %>
<%= text_with_tooltip h( @item.description ),
' Description of this Item ',
'item_description' %>
<% # embed this for testability and future JavaScript
%>
<%= h @item.id -%>
<% if @item.is_class? %>
<%= link_to "Add a new #{h @item.name}",
new_item_path + "?class_item=" + @item.id.to_s %>
<% end %>
<% # links to global pages/actions
%>
<% unless @popup_flag %>
<%= render :partial => "show_outbound_links" -%>
<% end %>
<% if @item.is_class? %>
<%= h filter_parenthetical @item.title -%>
<%
# we know that all the connections where this item is the object are
# located in the last array within @connection_list. Search through
# it for all of the connections where 'is_instance_of' is the predicate
iio_item_id = nil
@connection_list[-1].select do |maybe_iio_connection|
unless iio_item_id
if @item_hash[maybe_iio_connection.predicate_id].
name == 'is_instance_of'
iio_item_id = maybe_iio_connection.predicate_id
end
end
iio_item_id == maybe_iio_connection.predicate_id
end.
map{|connection| @item_hash[connection.subject_id] }.
sort{|a,b| last_word(filter_parenthetical(a.title)) <=>
last_word(filter_parenthetical(b.title)) }.
each do |item| %>
-
<%= link_to (h filter_parenthetical item.title), item_by_name_path(item.name) %>
<% end %>
<% end %>
This Item's Relationships
<% # populate bottom (connections referencing this item) section of page
unless @connection_list.empty? %>
<% # track things to do only once:
list_open_output = false
last_predicate_id = nil
last_obj_id = nil
table_open_output = false
@show_help_icon_used = false
@edit_help_icon_used = false
@delete_help_icon_used = false
@add_scalar_help_icon_used = false
@add_item_help_icon_used = false
item_counter = 0
array_of_arrays_of_connections = @connection_list.to_enum
# first, put all connections w/ current item-is-subject into indented list
begin
while true do # exit via break or exception
connection_array = array_of_arrays_of_connections.next
# check ID of first connection's subject item against "this" item's ID
break if connection_array[0].subject_id != @item.id
connection_array.each do |connection|
unless list_open_output
list_open_output = true
# question-icon for connections-list pop-up help
unless @popup_flag %>
<%= popup_help_icon "Help, connections referencing a item",
"Help:Popup/HeaderItemConnectionList" %>
<% end %>
<%= text_with_tooltip (h filter_parenthetical @item.title),
(h @item.name) %>
<% end
if last_predicate_id != connection.predicate_id
if last_predicate_id %>
<% end %>
-
<%= item = @item_hash[connection.predicate_id]
link_with_tooltip (h filter_parenthetical item.title ),
h( item.name ), item_by_name_path(item.name) %>
<% end
# now put any remaining connections into a table
if connection_array
loop do # until exception on .next at loop's end
unless table_open_output
table_open_output = true
# question-icon for connections-table pop-up help
unless @popup_flag %>
<%= popup_help_icon "Help, connections referencing a item",
"Help:Popup/HeaderItemConnectionTable" %>
<% end
output_table_open
end %>
<% connection_array.each do |connection| %>
<%= self_string_or_other_link(connection.subject_id) %>
|
<%= self_string_or_other_link(connection.predicate_id) %>
|
<% if connection.kind_of_obj == Connection::OBJECT_KIND_ITEM %>
<%= self_string_or_other_link(connection.obj_id) %>
<% else %>
<%= h connection.scalar_obj %>
<% end %>
|
<% if connection.id
generate_connection_links(connection,
item_by_name_path(@item.name) )
else
generate_inverse_link(@inverses_map[connection])
end %>
|
<% end %>
<%
connection_array = array_of_arrays_of_connections.next
end # loop over ..._connections iterator
end # if any connections to put in table
if table_open_output
output_table_close
end
end # unless @connection_list.empty?
%>
<% content_for :first_bottom_page_js do %>
<% end %>