Grima  2018-08
Whispering into Alma's ear
grima.php
Go to the documentation of this file.
1 <?php
2 #
3 # grima.php - pass messages to grima minions, display usage
4 #
5 # (c) 2017 Kathryn Lybarger. CC-BY-SA
6 #
7 require_once("grima-setup.php");
8 readfile('top.html');
9 require_once("grima-lib.php");
10 
11 function do_redirect($url) {
12  if(!headers_sent()) header("Location: $url");
13  $url_html = htmlspecialchars($url);
14  echo "<!DOCTYPE html><html><head><title>Redirect</title><meta http-equiv=refresh content='1; url=$url'></head><body><a href='$url_html'>Go here: $url_html</a></body></html>\n";
15  exit;
16 }
17 
18 $msg = isset($_REQUEST["msg"]) ? $_REQUEST["msg"] : "";
19 
20 #
21 # print <mms_id>
22 #
23 if (preg_match("/^print( .*)/",$msg,$m)) {
24  do_redirect("print.php?mms_id=" . ltrim($m[1]));
25 }
26 
27 #
28 # hierarchy <mms_id>
29 #
30 if (preg_match("/^hierarchy( .*)/",$msg,$m)) {
31  do_redirect("hierarchy.php?mms_id=" . ltrim($m[1]));
32 }
33 
34 #
35 # filter <mms_id> with <filter>
36 #
37 if (preg_match("/(norm|normalize|filter) (\d+) (with (.*))/",$msg,$m)) {
38  if (is_mmsid($m[2])) {
39  do_redirect("zf.php?mms_id=" . $m[2] . "&filter=" . $m[4]);
40  } else {
41  # MMS ID form
42  }
43 }
44 
45 #
46 # add mfhd <template> to <mms_id>
47 #
48 #
49 if (preg_match("/^add mfhd(.*)/",$msg,$m)) {
50  do_redirect("add_mfhd.php?query=" . ltrim($m[1]));
51 }
52 
53 #
54 # add tree <template> to <mms_id> with barcode <barcode>
55 #
56 #
57 
58 #
59 # insert oclcnum <number> into <mms_id>
60 #
61 if (preg_match("/insert oclcnum(.*)/",$msg,$m)) {
62  do_redirect("insert-oclcnum.php?query=" . urlencode(ltrim($m[1])));
63 }
64 
65 #
66 # overlay <mms_id> with <oclcnum>
67 # maybe more direct, but needs both APIs
68 #
69 
70 #
71 # unmerge phys/electronic
72 #
73 
74 #
75 # combine multiple bib/mfhd/item chains
76 #
77 
78 # FORMS
79 # PRINT
80 # add this to object?
81 ?>
82  <div class='panel panel-default bib'>
83  <div class='panel-heading'>
84  <h1 class='panel-title'>Print Record</h1>
85  </div>
86  <div class='panel-body'>
87  <dl class='dl-horizontal'>
88  <form method='post' action='print.php'>
89  <p>Print record
90  <input name='mms_id' size='20'/>
91  <input type='submit' value='submit' />
92  </p>
93  </form>
94  </dl>
95  </div>
96  </div>
97  <div class='panel panel-default bib'>
98  <div class='panel-heading'>
99  <h1 class='panel-title'>View Hierarchy</h1>
100  </div>
101  <div class='panel-body'>
102  <dl class='dl-horizontal'>
103  <form method='post' action='hierarchy.php'>
104  <p>View
105  <input name='mms_id' size='20'/>
106  <input type='submit' value='submit' />
107  </p>
108  </form>
109  </dl>
110  </div>
111  </div>
112  <div class='panel panel-default bib'>
113  <div class='panel-heading'>
114  <h1 class='panel-title'>
115  <span class='titleproper'>Insert OCLC Number</span>
116  </h1>
117  </div>
118  <div class='panel-body'>
119  <dl class='dl-horizontal'>
120  <form method='post' action='insert-oclcnum.php'>
121  <p>Insert oclcnum <input name='oclcnum' size='15' /> into
122  <input name='mms_id' size='20'/>
123  <input type='submit' value='submit' />
124  </p>
125  </form>
126  </dl>
127  </div>
128  </div>
129  </div>
130  </body>
131 </html>
$msg
Definition: grima.php:18
do_redirect($url)
Definition: grima.php:11