/sopac-facet-block.tpl.php

https://github.com/eby/sopac · PHP · 261 lines · 217 code · 14 blank · 30 comment · 52 complexity · b2a90fdcca601ca8b0c8874b9f58925a MD5 · raw file

  1. <?php
  2. $uri = $_GET['q'];
  3. $getvars = sopac_parse_get_vars();
  4. ?>
  5. <div id="sidetreecontrol"><a href="?#">Collapse All</a> | <a href="?#">Expand All</a></div>
  6. <ul id="facet" class="treeview">
  7. <?php
  8. $mat_count = count($locum_result['facets']['mat']);
  9. $search_formats = is_array($getvars['search_format']) ? $getvars['search_format'] : array();
  10. if ($mat_count) {
  11. if (!is_array($getvars['search_format']) || strtolower($_GET['search_format']) == 'all') {
  12. $li_prop = ' class="closed"';
  13. }
  14. else {
  15. $li_prop = NULL;
  16. }
  17. print "<li$li_prop><span class=\"folder\">by Format</span> <small>($mat_count)</small><ul>\n";
  18. foreach ($locum_result['facets']['mat'] as $mat_code => $mat_code_count) {
  19. if (in_array($mat_code, $search_formats)) {
  20. print '<li id="tree-kid" class="facet-item-selected"><strong>» ' . $locum_config['formats'][$mat_code] . "</strong></li>\n";
  21. }
  22. else {
  23. $getvars_tmp = $getvars;
  24. if ($getvars_tmp['search_format'][0] == 'all') {
  25. unset($getvars_tmp['search_format'][0]);
  26. }
  27. $getvars_tmp['search_format'][] = $mat_code;
  28. if (isset($getvars_tmp['page'])) {
  29. $getvars_tmp['page'] = '';
  30. }
  31. $link = l($locum_config['formats'][$mat_code], $uri, array('query' => sopac_make_pagevars(sopac_parse_get_vars($getvars_tmp))));
  32. print '<li id="tree-kid">» ' . $link . ' <small>(' . $mat_code_count . ")</small></li>\n";
  33. unset($getvars_tmp);
  34. }
  35. }
  36. print "</ul></li>\n";
  37. }
  38. if (variable_get('sopac_multi_branch_enable', 0)) {
  39. $facet_avail = $getvars['limit_avail'] ? $getvars['limit_avail'] : NULL;
  40. $avail_count = count($locum_result['facets']['avail']);
  41. if ($avail_count) {
  42. if (!$getvars['limit_avail'] && $getvars['limit_avail'] != 'any' ) {
  43. $li_prop = ' class="closed"';
  44. }
  45. else {
  46. $li_prop = NULL;
  47. }
  48. print "<li$li_prop><span class=\"folder\">by Availability</span> <small>($avail_count)</small><ul>\n";
  49. foreach ($locum_result['facets']['avail'] as $avail => $avail_count_indv) {
  50. $avail_name = $locum_config['branches'][$avail] ? $locum_config['branches'][$avail] : $avail;
  51. if ($avail_name == 'any') {
  52. $avail_name = t('Any Location');
  53. }
  54. if ($avail == $facet_avail) {
  55. print '<li id="tree-kid" class="facet-item-selected"><strong>» ' . $avail_name . "</strong></li>\n";
  56. }
  57. else {
  58. $getvars_tmp = $getvars;
  59. $getvars_tmp['limit_avail'] = urlencode($avail);
  60. if (isset($getvars_tmp['page'])) {
  61. $getvars_tmp['page'] = '';
  62. }
  63. $link = l($avail_name, $uri, array('query' => sopac_make_pagevars(sopac_parse_get_vars($getvars_tmp))));
  64. print '<li id="tree-kid">» ' . $link . ' <small>(' . $avail_count_indv . ")</small></li>\n";
  65. unset($getvars_tmp);
  66. }
  67. }
  68. print "</ul></li>\n";
  69. }
  70. }
  71. $facet_age = is_array($getvars['age']) ? $getvars['age'] : array();
  72. $age_count = count($locum_result['facets']['ages']);
  73. if ($age_count) {
  74. if (!is_array($getvars['age'])) {
  75. $li_prop = ' class="closed"';
  76. }
  77. else {
  78. $li_prop = NULL;
  79. }
  80. print "<li$li_prop><span class=\"folder\">by Age Group</span> <small>($age_count)</small><ul>\n";
  81. foreach ($locum_result['facets']['ages'] as $age => $age_count_indv) {
  82. $age_name = $locum_config['ages'][$age] ? $locum_config['ages'][$age] : $age;
  83. if (in_array($age, $facet_age)) {
  84. print '<li id="tree-kid" class="facet-item-selected"><strong>» ' . $age_name . "</strong></li>\n";
  85. }
  86. else {
  87. $getvars_tmp = $getvars;
  88. $getvars_tmp['age'][] = urlencode($age);
  89. if (isset($getvars_tmp['page'])) {
  90. $getvars_tmp['page'] = '';
  91. }
  92. $link = l($age_name, $uri, array('query' => sopac_make_pagevars(sopac_parse_get_vars($getvars_tmp))));
  93. print '<li id="tree-kid">» ' . $link . ' <small>(' . $age_count_indv . ")</small></li>\n";
  94. unset($getvars_tmp);
  95. }
  96. }
  97. print "</ul></li>\n";
  98. }
  99. $facet_series = is_array($getvars['facet_series']) ? $getvars['facet_series'] : array();
  100. if (count($locum_result['facets']['series'])) {
  101. foreach ($locum_result['facets']['series'] as $series => $series_count) {
  102. $ser_arr = explode(';', $series);
  103. $ser_clean = trim($ser_arr[0]);
  104. //$series_result_unweeded[$ser_clean]++;
  105. if ($series_count >= 1) {
  106. $series_result[$ser_clean] += $series_count;
  107. }
  108. }
  109. $series_count = count($series_result);
  110. if ($series_count) {
  111. if (!is_array($getvars['facet_series'])) {
  112. $li_prop = ' class="closed"';
  113. }
  114. else {
  115. $li_prop = NULL;
  116. }
  117. print "<li$li_prop><span class=\"folder\">by Series</span> <small>($series_count)</small><ul>\n";
  118. foreach ($series_result as $series => $series_name_count) {
  119. if (in_array($series, $facet_series)) {
  120. print '<li id="tree-kid" class="facet-item-selected"><strong>» ' . $series . "</strong></li>\n";
  121. }
  122. else {
  123. $getvars_tmp = $getvars;
  124. $getvars_tmp['facet_series'][] = urlencode($series);
  125. if (isset($getvars_tmp['page'])) {
  126. $getvars_tmp['page'] = '';
  127. }
  128. $link = l($series, $uri, array('query' => sopac_make_pagevars(sopac_parse_get_vars($getvars_tmp))));
  129. print '<li id="tree-kid">» ' . $link . ' <small>(' . $series_name_count . ")</small></li>\n";
  130. unset($getvars_tmp);
  131. }
  132. }
  133. print "</ul></li>\n";
  134. }
  135. }
  136. $facet_lang = is_array($getvars['facet_lang']) ? $getvars['facet_lang'] : array();
  137. $lang_count = count($locum_result['facets']['lang']);
  138. if ($lang_count) {
  139. if (!is_array($getvars['facet_lang'])) {
  140. $li_prop = ' class="closed"';
  141. }
  142. else {
  143. $li_prop = NULL;
  144. }
  145. print "<li$li_prop><span class=\"folder\">by Language</span> <small>($lang_count)</small><ul>\n";
  146. foreach ($locum_result['facets']['lang'] as $lang => $lang_code_count) {
  147. if (in_array($lang, $facet_lang)) {
  148. print '<li id="tree-kid" class="facet-item-selected"><strong>» ' . ucfirst($locum_config['languages'][$lang]) . "</strong></li>\n";
  149. }
  150. else {
  151. $getvars_tmp = $getvars;
  152. $getvars_tmp['facet_lang'][] = urlencode($lang);
  153. if (isset($getvars_tmp['page'])) {
  154. $getvars_tmp['page'] = '';
  155. }
  156. $link = l(ucfirst($locum_config['languages'][$lang]), $uri, array('query' => sopac_make_pagevars(sopac_parse_get_vars($getvars_tmp))));
  157. print '<li id="tree-kid">» ' . $link . ' <small>(' . $lang_code_count . ")</small></li>\n";
  158. unset($getvars_tmp);
  159. }
  160. }
  161. print "</ul></li>\n";
  162. }
  163. $facet_year = is_array($getvars['facet_year']) ? $getvars['facet_year'] : array();
  164. $year_count = count($locum_result['facets']['pub_year']);
  165. if ($year_count) {
  166. if (!is_array($getvars['facet_year'])) {
  167. $li_prop = ' class="closed"';
  168. }
  169. else {
  170. $li_prop = NULL;
  171. }
  172. print "<li$li_prop><span class=\"folder\">by Pub. Year</span> <small>($year_count)</small><ul>\n";
  173. foreach ($locum_result['facets']['pub_year'] as $year => $pub_year_count) {
  174. if (in_array($year, $facet_year)) {
  175. print '<li id="tree-kid" class="facet-item-selected"><strong>» ' . $year . "</strong></li>\n";
  176. }
  177. elseif ($year <= date('Y')) {
  178. $getvars_tmp = $getvars;
  179. $getvars_tmp['facet_year'][] = urlencode($year);
  180. if (isset($getvars_tmp['page'])) {
  181. $getvars_tmp['page'] = '';
  182. }
  183. $link = l($year, $uri, array('query' => sopac_make_pagevars(sopac_parse_get_vars($getvars_tmp))));
  184. print '<li id="tree-kid">» ' . $link . ' <small>(' . $pub_year_count . ")</small></li>\n";
  185. unset($getvars_tmp);
  186. }
  187. }
  188. print "</ul></li>\n";
  189. }
  190. $facet_decade = is_array($getvars['facet_decade']) ? $getvars['facet_decade'] : array();
  191. $decade_count = count($locum_result['facets']['pub_decade']);
  192. if ($decade_count) {
  193. if (!is_array($getvars['facet_decade'])) {
  194. $li_prop = ' class="closed"';
  195. }
  196. else {
  197. $li_prop = NULL;
  198. }
  199. print "<li$li_prop><span class=\"folder\">by Decade</span> <small>($decade_count)</small><ul>\n";
  200. foreach ($locum_result['facets']['pub_decade'] as $decade => $pub_decade_count) {
  201. if (in_array($decade, $facet_decade)) {
  202. print '<li id="tree-kid" class="facet-item-selected"><strong>» ' . $decade . "-" . ($decade + 9) . "</strong></li>\n";
  203. }
  204. elseif ($decade <= date('Y')) {
  205. $getvars_tmp = $getvars;
  206. $getvars_tmp['facet_decade'][] = urlencode($decade);
  207. if (isset($getvars_tmp['page'])) {
  208. $getvars_tmp['page'] = '';
  209. }
  210. $link = l($decade . '-' . ($decade + 9), $uri, array('query' => sopac_make_pagevars(sopac_parse_get_vars($getvars_tmp))));
  211. print '<li id="tree-kid">» ' . $link . ' <small>(' . $pub_decade_count . ")</small></li>\n";
  212. unset($getvars_tmp);
  213. }
  214. }
  215. print "</ul></li>\n";
  216. }
  217. /* Uncomment for subjects facet
  218. $facet_subject = is_array($getvars['facet_subject']) ? $getvars['facet_subject'] : array();
  219. $subject_count = count($locum_result['facets']['subject']);
  220. if ($subject_count) {
  221. if (!is_array($getvars['facet_subject'])) {
  222. $li_prop = ' class="closed"';
  223. }
  224. else {
  225. $li_prop = NULL;
  226. }
  227. print "<li$li_prop><span class=\"folder\">by Subject</span> <small>($subject_count)</small><ul>\n";
  228. foreach ($locum_result['facets']['subject'] as $subject => $subject_code_count) {
  229. if (in_array($subject, $facet_subject)) {
  230. print '<li id="tree-kid" class="facet-item-selected"><strong>» ' . $subject . "</strong></li>\n";
  231. }
  232. else {
  233. $getvars_tmp = $getvars;
  234. $getvars_tmp['facet_subject'][] = urlencode($subject);
  235. if (isset($getvars_tmp['page'])) {
  236. $getvars_tmp['page'] = '';
  237. }
  238. $link = l($subject, $uri, array('query' => sopac_make_pagevars(sopac_parse_get_vars($getvars_tmp))));
  239. print '<li id="tree-kid">» ' . $link . ' <small>(' . $subject_code_count . ")</small></li>\n";
  240. unset($getvars_tmp);
  241. }
  242. }
  243. print "</ul></li>\n";
  244. }
  245. */
  246. ?>
  247. </ul>