1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php

function faculty_admin_template_settings() {  

	$form['template1'] = array(
	 '#type' => 'fieldset',
	 '#title' => 'Faculty detail page template',
	 '#collapsible' => TRUE,
	 '#collapsed' => TRUE,
	);

  // Load the default faculty template if needed
  global $faculty_detail_template_default;

	$form['template1']['faculty_detail_template'] = array( 
    '#type' => 'textarea',
    '#title' => t('Faculty detail page template'),
    '#prefix' => t('<p>Enter code to build the faculty detail pages. Include <em>&lt;?php ?&gt;</em> tags.</p>'),
    '#rows' => 40,
		'#default_value' => variable_get('faculty_detail_template', $faculty_detail_template_default),
  );
  
  $form['variables'] = array(
	  '#type' => 'fieldset',
	  '#title' => 'Available variables',
	  '#collapsible' => TRUE,
	  '#collapsed' => TRUE,
	);
	
	$form['variables']['info'] = array(
	  '#type' => 'item',
	  '#value' => t('Below are the available variables for use. Some variables may not be available for all people. Most variables do not output HTML elements, so you will need to wrap them in HTML tags. Be sure to include <em>&lt;?php ?&gt;</em> tags.<ul>
    <li>$firstname</li>
    <li>$lastname</li>
    <li>$degree</li>
    <li>$mission</li>
    <li>$email</li>
    <li>$office_phone</li>
    <li>$biography</li>
    <li>$research_interests</li>
    <li>$clinical_interests</li>
    <li>$research_overview</li>
    <li>$research_summary</li>
    <li>$current_projects</li>
    <li>$organizations</li>
    <li>$academic_location</li>
    <li>$professional_awards</li>
    <li>$education</li>
    <li>$address</li>
    <li>$photo</li>
    <li>$departments</li>
    <li>$titles</li>
    <li>$featured_publications</li>
    <li>$related_links</li>
    <li>$current_projects</li>
    </ul>'),
	);

  $form['#submit'][] = 'faculty_submit';

  return system_settings_form($form);
}

function faculty_submit(&$form, &$form_state){ 
  // Clear caches for list and detail pages.
  cache_clear_all('faculty_list', 'cache', TRUE);
  cache_clear_all('faculty_detail_load', 'cache', TRUE);
  
  // Check if the template variable exists, if not, create it (for when reset is clicked)
  $template = variable_get('faculty_detail_template', NULL);
  if (!$template) {
    global $faculty_detail_template_default;
    variable_set('faculty_detail_template', $faculty_detail_template_default);
  }
}


// Define global variable to be used to set default detail template value.
global $faculty_detail_template_default;
$faculty_detail_template_default =
'<?php print $photo; ?><br />

<?php if($titles): ?>
<?php print $titles; ?>
<?php endif; ?>

<?php if($address): ?>
<p><?php print $address; ?></p>
<?php endif; ?>

<?php if($email): ?>
<p><?php print $email; ?></p>
<?php endif; ?>

<?php if($office_phone): ?>
<?php print $office_phone; ?>
<?php endif; ?>

<?php if($education): ?>
<h2>Education</h2>
<?php print $education; ?>
<?php endif; ?>

<?php if($biography): ?>
<h2>Biography</h2>
<p><?php print $biography; ?></p>
<?php endif; ?>';