/[drupal]/contributions/modules/family/source.inc
ViewVC logotype

Contents of /contributions/modules/family/source.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (show annotations) (download) (as text)
Sat Dec 6 03:18:15 2008 UTC (11 months, 3 weeks ago) by pyutaros
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +0 -0 lines
File MIME type: text/x-php
#322607 by Microbe:  Ascendants and Descendants tabs appear on every node type
#326432 by Microbe:  New 6.x-1.0-beta2 instalation - warning: mysql_fetch_array()
#339263 by Microbe:  Misspelling of word "Birth" in table
#339265 by Microbe:  Marriage type fields requested, in addition to "Religious"
#331459 by Microbe:  GEDCOM data confused on import
1 <?php
2 // $Id: source.inc,v 1.2.2.1 2008/10/09 01:55:57 pyutaros Exp $
3 /**
4 * Implementation of hook_access().
5 */
6 function family_source_access($op, $node) {
7 if ($op == 'create' || $op == 'update' || $op == 'delete') {
8 return user_access('add/edit/delete family');
9 }
10 if ($op == 'view') {
11 return family_check_privacy($node->fid);
12 }
13 }
14
15 /**
16 * Implementation of hook_view().
17 */
18 function family_source_view(&$node, $teaser = FALSE, $page = FALSE) {
19 $node = node_prepare($node, $teaser);
20 // $fid = db_result(db_query("SELECT fid FROM {family_facts} WHERE nid= %d", $node->nid));
21 // $node->body = family_view_indi($node->fid) . $node->body;
22 // $node->teaser = family_view_indi($node->fid) . $node->teaser;
23 $node->content['family_individual_view'] = array(
24 '#value' => theme($teaser? 'family_source_teaser':'family_source_body', $node),
25 '#weight' => 0,
26 );
27
28 return $node;
29 }
30
31 function theme_family_source_teaser($node) {
32 return family_view_source($node->fid);
33 }
34 function theme_family_source_body($node) {
35 return family_view_source($node->fid);
36 }
37 /*
38 * Implements showing sources. (NOT source citations, they use the same code (SOUR), but
39 * sourcecs have xrefs, citations don't, and a slightly different structure.
40 * See family_view_citation)
41 */
42 function family_view_source($fid = 0) {
43 if(func_num_args() == 0) {
44 return "<p><em>We are sorry, but you did not enter the Fact Id for a know source.</em></p>";
45 }
46 $content="";
47 //Display all source data
48 $fact = family_get_fact_by_fid($fid);
49 $subfacts = family_get_subfacts($fid);
50 if($sour_titl = $subfacts['TITL'][0]['value']){$content .= "<h1>$sour_titl</h1>";}
51 if($sour_abbr = $subfacts['ABBR'][0]['value']){$content .= "Source Title:$sour_abbr<br />";}
52 if($sour_auth = $subfacts['AUTH'][0]['value']){
53 $content .= "Authority: $sour_auth".family_get_cont($subfacts['AUTH'][0]['fid'])."<br />";
54 }
55 if($sour_publ = $subfacts['PUBL'][0]['value']){
56 $content .= "Publisher: $sour_publ".family_get_cont($subfacts['PUBL'][0]['fid'])."<br />";
57 }
58 if($sour_data = $subfacts['DATA'][0]['value']){
59 $datafacts = family_get_subfacts($subfacts['DATA'][0]['fid']);
60 if($data_date = $datafacts['DATE'][0]['value']){
61 $content .= "Date: $data_date <br />";
62 }
63 if($datafacts['EVEN']){
64 $content .= "Events recorded: <ul>";
65 foreach($datafacts['EVEN'] as $iter => $even_arr){
66 $content .= "<li>".$even_arr['value'];
67 if($evenfacts = family_get_subfacts($even_arr['fid'])){
68 $fact_arr = array("Places: ".$evenfacts['PLAC'][0]['value'],
69 "Dates: " .$evenfacts['DATE'][0]['value'] );
70 $content = implode('<br />', $fact_arr);
71 }
72 $content .="</li>";
73 }
74 $content .= "</ul>";
75 }
76 if($data_agnc = $datafacts['AGNC'][0]['value']){$content .= "Responsible Agency:$data_agnc<br />";}
77 if($datafacts['NOTE']){
78 $content .= '<p>Notes: ';
79 foreach($subfacts['NOTE'] as $idx => $note) {
80 $content .= '<p>'.$note['value'].family_get_cont($note['fid']).'</p>';
81 }
82 $content .= '</p>';
83 }
84 }
85 if($subfacts['NOTE']){
86 $content .= '<p>Notes: ';
87 foreach($subfacts['NOTE'] as $idx => $note) {
88 $content .= '<p>'.$note['value'].family_get_cont($note['fid']).'</p>';
89 }
90 $content .= '</p>';
91 }
92 $content .= '<hr />'; //Break before citation listings
93 /*
94 * TODO: Find all linking source citations and list them each within types:
95 * INDI, FAM, NOTE (Never seen this on a root level...), REPO, SUBM, SUBN
96 * This probably requires each supporte type to have a view option to link to.
97 */
98 //
99 $seen_fids = array();
100 $indi_header = array(
101 'Surname',
102 'Given Name',
103 'Sex',
104 'Birth Date',
105 //'Birth Place',
106 'Death Date',
107 //'Death Place'
108 );
109 $indi_facts = array();
110 $fam_header = array(
111 'Husband',
112 'Wife',
113 'Date',
114 'Place'
115 );
116 $fam_facts = array();
117 $citations = db_query("SELECT fid, nid, xref, fact_code AS code, fact_value AS value "
118 . "FROM {family_facts} "
119 . "WHERE fact_value = '%s' ", '@'.$fact['xref'].'@');
120 while($citation = db_fetch_array($citations)){
121 $root = family_get_fact_root($citation['fid']);
122 if($seen_fids[$root['fid']]){ continue; } //Kinda Perlish, I know, but it works.
123 else { $seen_fids[$root['fid']] = true; }
124 if(strcmp($root['fact_code'],"INDI") == 0){
125 $subfacts = family_get_subfacts($root['fid']);
126 $birthfacts = family_get_subfacts($subfacts['BIRT'][0]['fid']);
127 $deathfacts = family_get_subfacts($subfacts['DEAT'][0]['fid']);
128 $name = $subfacts['NAME'][0]['value'];
129 $name_arr = family_get_display_name($name);
130 $indi_facts[$root['fid']] = array(
131 'SURN' => l( $name_arr['SURN'], "node/".$root['nid']),
132 'GIVN' => l( $name_arr['GIVN'], "node/".$root['nid']),
133 'SEX' => l( $subfacts['SEX' ][0]['value'], "node/".$root['nid']),
134 'BIRTD'=> l($birthfacts['DATE' ][0]['value'], "node/".$root['nid']),
135 //'BIRTP' => family_make_link($fid, $birthfacts['PLAC']['value']),
136 'DEATD'=> l($deathfacts['DATE' ][0]['value'], "node/".$root['nid']),
137 //'DEATP' => family_make_link($fid, $deathfacts['PLAC']['value'])
138 );
139 }
140 elseif(strcmp($root['fact_code'],"FAM") == 0){
141 $subfacts = family_get_subfacts($root['fid']);
142 $marr_facts = family_get_subfacts($subfacts['MARR'][0]['fid']);
143 $couple = family_get_fam_by_famid($root['fid'], array('HUSB','WIFE'));
144 $couple_husb = family_get_subfacts($couple['HUSB'][0]['fid']);
145 $couple_wife = family_get_subfacts($couple['WIFE'][0]['fid']);
146 $husb_name = family_get_display_name($couple_husb['NAME'][0]['value']);
147 $wife_name = family_get_display_name($couple_wife['NAME'][0]['value']);
148 $fam_facts[$root['fid']] = array(
149 'HUSB' => l($husb_name['NAME'],"node/".$couple['HUSB'][0]['nid']),
150 'WIFE' => l($wife_name['NAME'],"node/".$couple['WIFE'][0]['nid']),
151 'DATE' => $marr_facts['DATE'][0]['value'],
152 'PLAC' => $marr_facts['PLAC'][0]['value']
153 );
154 }
155 }
156 $content .= '<div class="sources-listing">'
157 . "<h3>Individuals with Citations from this Source:</h3>"
158 . '<div class="family-index">'.theme('table', $indi_header, $indi_facts).'</div>'
159 . "<h3>Families with Citations from this Source:</h3>"
160 . '<div class="family-index">'.theme('table', $fam_header, $fam_facts).'</div>'
161 . '</div>';
162 return($content);
163 }
164
165 function family_view_source_short($fid) {
166 $content="";
167 //Display all source data
168 $subfacts = family_get_subfacts($fid);
169 //Order of display preference decending (we want the abbreviated title if we can)
170 $title = 'No Title';
171 if($subfacts['TITL']){
172 $title = $subfacts['TITL'][0]['value'];
173 }
174 if($subfacts['ABBR']){
175 $title = $subfacts['ABBR'][0]['value'];
176 }
177 $content .= $title;
178 if($sour_publ = $subfacts['PUBL'][0]['value']){
179 $content .= "(<i>$sour_publ".family_get_cont($subfacts['PUBL'][0]['fid'])."</i>)";
180 }
181 return($content);
182 }
183
184 function family_view_repository($fid) {
185 $rep_fact = family_get_fact_by_fid($fid);
186 $subfacts = family_get_subfacts($fid);
187
188 $content .= '<h3>'.$subfacts['NAME'][0]['value'].'</h3>';
189
190 if($subfacts['ADDR']) {
191 $content .= '<p>'. family_get_address($subfacts['ADDR'][0]) . '</p>';
192 }
193
194 if ($subfacts['PHON']) {
195 $content .= "<p>Phone: <ol>";
196 foreach($subfacts['PHON'] as $idx => $phone) {
197 $content .= '<li>'.$phone['value'].'</li>';
198 }
199 $content .= "</ol></p>";
200 }
201 if ($subfacts['EMAIL']) {
202 $content .= "<p><ol>";
203 foreach($subfacts['EMAIL'] as $idx => $email) {
204 $content .= '<li>'.$email['value'].'</li>';
205 }
206 $content .= "</ol></p>";
207 }
208 if ($subfacts['FAX']) {
209 $content .= "<p>Fax: <ol>";
210 foreach($subfacts['FAX'] as $idx => $fax) {
211 $content .= '<li>'.$fax['value'].'</li>';
212 }
213 $content .= "</ol></p>";
214 }
215 if ($subfacts['WWW']) {
216 $content .= "<p><ol>";
217 foreach($subfacts['WWW'] as $idx => $www) {
218 $content .= '<li><a href="'.$www['value'].'">'.$www['value'].'</a></li>';
219 }
220 $content .= "</ol></p>";
221 }
222 if($subfacts['NOTE']){
223 $content .= '<p>Notes: ';
224 foreach($subfacts['NOTE'] as $idx => $note) {
225 $content .= '<p>'.$note['value'].family_get_cont($note['fid']).'</p>';
226 }
227 $content .= '</p>';
228 }
229 }
230
231 function family_view_repository_short($fid) {
232 $rep_fact = family_get_fact_by_fid($fid);
233 if($rep_fact['nid'] > 0) {
234 $link_path = "node/".$rep_fact['nid'];
235 }
236 else {
237 $link_path = "family/view/repository/".$rep_fact['fid'];
238 }
239 return l(family_get_subvalue_by_code('NAME', $fid), $link_path);
240 }
241
242 function family_view_repository_citation($fid) {
243 if(func_num_args() == 0) {
244 return "<em>We are sorry, but you did not enter the Fact Id for a know repository citation.</em>";
245 }
246 elseif(func_num_args() > 1){ //Second value passed could be the xref pointer
247 $xref = func_get_arg(1); //to the owning repository.
248 }
249 else {
250 $xref = family_get_value_by_fid($fid);
251 }
252 $subfacts = family_get_subfacts($fid);
253 $repo_fact = family_get_fact_by_xref($xref);
254
255 //Link to the source being cited
256 if($repo_fact['nid'] > 0) { //I don't know if this case will ever appear, but just in case...
257 $link_path = "node/".$repo_fact['nid'];
258 }
259 else{
260 $link_path = "family/view/source/".$repo_fact['fid'];
261 }
262 $content .= "<h3>".l(family_view_source_short($repo_fact['fid']),$link_path)."</h3>";
263
264 //Display all repository citation data
265
266 if($subfacts['NOTE']){
267 $content .= '<p>Notes: ';
268 foreach($subfacts['NOTE'] as $idx => $note) {
269 $content .= '<p>'.$note['value'].family_get_cont($note['fid']).'</p>';
270 }
271 $content .= '</p>';
272 }
273 if($subfacts['CALN']){
274 $content .= '<p>Call Number(s): <ul>';
275 foreach($subfacts['CALN'] as $idx => $caln) {
276 $content .= '<li>'.$caln['value'];
277 if($media_fact = family_get_subfact_by_code('MEDI', $caln['fid']) ) {
278 $content .= ', ('.$media_fact['value'].')';
279 }
280 $content .= '</li>';
281 }
282 $content .= '</ul></p>';
283 }
284
285 return($content);
286 }
287
288 function family_view_citation($fid) {
289 if(func_num_args() == 0) {
290 return "<em>We are sorry, but you did not enter the Fact Id for a know citation.</em>";
291 }
292 elseif(func_num_args() > 1){ //Second value passed could be the xref pointer
293 $xref = func_get_arg(1); //to the source being cited.
294 }
295 else {
296 $xref = family_get_value_by_fid($fid);
297 }
298 $subfacts = family_get_subfacts($fid);
299 $sour_fact = family_get_fact_by_xref($xref);
300
301 //Link to the source being cited
302 if($sour_fact['nid'] > 0) { //I don't know if this case will ever appear, but just in case...
303 $link_path = "node/".$sour_fact['nid'];
304 }
305 else{
306 $link_path = "family/view/source/".$sour_fact['fid'];
307 }
308 $content .= "<h3>".l(family_view_source_short($sour_fact['fid']),$link_path)."</h3>";
309
310 //Display all citation data
311 if($sour_page = $subfacts['PAGE'][0]['value']){$content .= ", pg(s) $sour_page<br />";}
312 if($sour_even = $subfacts['EVEN'][0]['value']){
313 $content .= "Event Type: $sour_even";
314 if($even_role = family_get_subvalue_by_code('ROLE',$subfacts['EVEN'][0]['fid'])){
315 $content .= ", $even_role<br />";
316 }
317 }
318 if($subfacts['DATA']){
319 $datafacts = family_get_subfacts($subfacts['DATA'][0]['fid']);
320 if($data_date = $datafacts['DATE'][0]['value']){
321 $content .= "Date: $data_date <br />";
322 }
323 if($data_text = $datafacts['TEXT'][0]['value']){
324 $content .= "Text from source: $data_text"
325 . family_get_cont($datafacts['TEXT'][0]['fid'])."<br />";
326 }
327 }
328 if($sour_quay = $subfacts['QUAY'][0]['value']){$content .= "Quality Assesment: $sour_quay<br />";}
329 if($subfacts['NOTE']){
330 $content .= '<p>Notes: ';
331 foreach($subfacts['NOTE'] as $idx => $note) {
332 $content .= '<p>'.$note['value'].family_get_cont($note['fid']).'</p>';
333 }
334 $content .= '</p>';
335 }
336
337 return($content);
338 }
339
340 function family_view_citation_short($fid) {
341 $subfacts = family_get_subfacts($fid);
342 if(func_num_args() > 1){
343 $xref = func_get_arg(1);
344 }
345 else {
346 $xref = family_get_value_by_fid($fid);
347 }
348 $sour_fact = family_get_fact_by_xref($xref);
349 //Display all citation data
350 if($sour_fact['nid'] > 0) { //I don't know if this case will ever appear, but just in case...
351 $link_path = "node/".$sour_fact['nid'];
352 }
353 else{
354 $link_path = "family/view/source/".$sour_fact['fid'];
355 }
356 $content .= family_view_source_short($sour_fact['fid']);
357 if($subfacts['PAGE']){
358 $content .= ", pg(s) ".$subfacts['PAGE'][0]['value'];
359 }
360
361 return($content);
362 }
363
364 /**
365 * Implementation of family_source_load().
366 * This function will grab all the descriptive data for an individual
367 * Primary use is for filling in form data to preform an edit
368 * [Code mostly taken from family_individual_load() & family_view_source()]
369 *
370 * Returns an array of additions, following convention of individual load
371 */
372 function family_source_load($fid) {
373 $additions->fid = $fid;
374
375 return ($additions);
376 }

  ViewVC Help
Powered by ViewVC 1.1.2