paristemi
[ class tree: paristemi ] [ index: paristemi ] [ all elements ]

Source for file index.php

Documentation is available at index.php

  1. <?php
  2. /**
  3. * <b>Library Section</b><br />
  4. * The library section lists the library categories and library catalog items.
  5. * This section is searchable.
  6. * @author Kristen O'Brien <kristen_paristemi-com>
  7. * @copyright Copyright 2004, Kristen O'Brien
  8. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  9. * @link http://www.paristemi.com Paristemi Main Site
  10. * @package paristemi
  11. * @subpackage paristemi_business_logic
  12. * @since Build 0.4
  13. * @version Build 0.7
  14. * @filesource
  15. */
  16. /**
  17. * Include the constants file and all of the files in the include list
  18. */
  19. if(ltrim(dirname($_SERVER['SCRIPT_FILENAME'])) == "" || !file_exists($_SERVER['DOCUMENT_ROOT']."/constants.php")) {
  20. if(!file_exists("../constants.php")) { require_once("../public_html/constants.php"); }
  21. else { require_once("../constants.php"); }
  22. }
  23. else { require_once($_SERVER['DOCUMENT_ROOT']."/constants.php"); }
  24. foreach($INCLUDE_LIST as $includefile) { require_once $includefile; }
  25.  
  26. $db = new Database();
  27. $db_lib = $db->GetClass('library');
  28.  
  29. $id="";$cat="";$group="";$item="";$searchterm="";$stitle="";$sauth="";$lbegin=0;$searchflg=false;
  30. $sdesc="";$sisbn="";$scatnum="";$sformat="";$scategory="";$skeywords="";$scount=0;$scntflg=false;
  31. if(getenv("QUERY_STRING")) {
  32. if(isset($HTTP_GET_VARS['id'])) {$id = $HTTP_GET_VARS['id'];}
  33. if(isset($HTTP_GET_VARS['cat'])) {$cat = $HTTP_GET_VARS['cat'];}
  34. if(isset($HTTP_GET_VARS['group'])) {$group = $HTTP_GET_VARS['group'];}
  35. if(isset($HTTP_GET_VARS['item'])) {$item = $HTTP_GET_VARS['item'];}
  36. if(isset($HTTP_GET_VARS['SearchTerm'])) {
  37. $searchterm = $HTTP_GET_VARS['SearchTerm'];$searchflg=true; }
  38. if(isset($HTTP_GET_VARS['title'])) {$stitle = $HTTP_GET_VARS['title'];}
  39. if(isset($HTTP_GET_VARS['author'])) {$sauth = $HTTP_GET_VARS['author'];}
  40. if(isset($HTTP_GET_VARS['description'])) {$sdesc = $HTTP_GET_VARS['description'];}
  41. if(isset($HTTP_GET_VARS['isbn'])) {$sisbn = $HTTP_GET_VARS['isbn'];}
  42. if(isset($HTTP_GET_VARS['catnum'])) {$scatnum = $HTTP_GET_VARS['catnum'];}
  43. if(isset($HTTP_GET_VARS['format'])) {$sformat = $HTTP_GET_VARS['format'];}
  44. if(isset($HTTP_GET_VARS['category'])) {$scategory = $HTTP_GET_VARS['category'];}
  45. if(isset($HTTP_GET_VARS['keywords'])) {$skeywords = $HTTP_GET_VARS['keywords'];}
  46. if(isset($HTTP_GET_VARS['lbegin'])) {$lbegin = $HTTP_GET_VARS['lbegin'];}
  47. if(isset($HTTP_GET_VARS['scount'])) {$scount = $HTTP_GET_VARS['scount'];$scntflg=true;}
  48. }
  49. if($id != "") {
  50. $value =& $db_lib->GetLibraryData($id);
  51. $pagesubtitle = $S_ITEM." - ".$value->Title; }
  52. else if($cat != "") { $pagesubtitle = $S_CATEGORY." - ".$cat; }
  53. else if($searchterm != "") { $pagesubtitle = $S_SEARCH." - ".ucwords(strtolower($searchterm)); }
  54. else { $pagesubtitle = $S_CATALOG; }
  55. require_once $HTTP_DOCUMENT_ROOT.$INCLUDE_PATH.$HEADER.
  56. "?pagetitle=".str_replace(" ","%20",htmlentities($S_LIBRARY)).
  57. "&pagesubtitle=".str_replace(" ","%20",htmlentities(stripslashes($pagesubtitle))).
  58. "&pagedesc=".str_replace(" ","%20",htmlentities($CHURCH_NAME." ".$S_DESC_LIBRARY));
  59.  
  60. $smarty = UtilSmarty::createSmarty();
  61.  
  62. $categories = $db_lib->GetCategoriesUsed();
  63. $sidesection = array();
  64. $sidesection['Title'] = $S_LIBRARY." ".$S_CATALOG;
  65. $sidesection['Links'] = array();
  66. foreach($categories as $category) {
  67. $sidesection['Links'][]= array('LinkPath' => $HTTP_DOCUMENT_ROOT.$LIBRARY_DIR.
  68. $LIBRARY_FILE."?cat=".$category,
  69. 'LinkText' => $category);
  70. }
  71. $smarty->assign('sidesections',array($sidesection));
  72. $smarty->assign('searchformname','librarysearch');
  73. $smarty->assign('searchformfile',$LIBRARY_FILE);
  74. $smarty->assign('searchconstraints',
  75. array(array('name'=>'title','title'=>$S_TITLE),
  76. array('name'=>'author','title'=>$S_AUTHOR),
  77. array('name'=>'isbn','title'=>$S_ISBN),
  78. array('name'=>'catnum','title'=>$S_CATALOG." ".$S_NUMBER),
  79. array('name'=>'format','title'=>$S_FORMAT),
  80. array('name'=>'category','title'=>$S_CATEGORY),
  81. array('name'=>'keywords','title'=>$S_KEYWORDS)));
  82. $smarty->assign('searchsubmittitle',$S_SEARCH);
  83. $smarty->assign('bottomnote',$S_NOTE_LIBRARY);
  84. if(getenv("QUERY_STRING")) {
  85. if($searchflg)
  86. {
  87. if($searchterm == "") {
  88. $finalresults =& $db_lib->GetAllLibraryDataByLimit($LISTING_LIMIT,$lbegin);
  89. $scount = count($db_lib->GetAllLibraryData());
  90. }
  91. else {
  92. $sterm = $searchterm;
  93. $atype = array();
  94. if($stitle != null) { $atype[] = "title"; }
  95. if($sauth != null) { $atype[] = "author"; }
  96. if($sdesc != null) { $atype[] = "description"; }
  97. if($sisbn != null) { $atype[] = "isbn"; }
  98. if($scatnum != null) { $atype[] = "catnum"; }
  99. if($sformat != null) { $atype[] = "format"; }
  100. if($scategory != null) { $atype[] = "category"; }
  101. if($skeywords != null) { $atype[] = "keywords"; }
  102. $finalresults =& $db_lib->SearchLibrary($searchterm,$atype,$LISTING_LIMIT,$lbegin);
  103. if(!$scntflg) {$scount = $db_lib->SearchLibraryCount($searchterm,$atype);}
  104. }
  105. $smarty->assign('heading',$S_SEARCH." ".$S_RESULTS." (".$scount." ".$S_RESULTS.")");
  106. if($finalresults != null) {
  107. $listelements = array();
  108. foreach($finalresults as $item) {
  109. $linktext = $item->Title." by ";
  110. if($item->Author != "") { $linktext .= $item->Author; }
  111. else if ($item->Editor != "") { $linktext .= $item->Editor; }
  112. else { $linktext .= $item->Publisher; }
  113. $linktext .= " [".$item->CatalogNumber."]";
  114. $listelements[] = array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$LIBRARY_DIR.$LIBRARY_FILE."?id=".$item->ID,
  115. 'Title'=>$linktext);
  116. }
  117. $smarty->assign('listelements',$listelements);
  118. $bottomlinks = array();
  119. if($scount >= $lbegin-$LISTING_LIMIT && $lbegin-$LISTING_LIMIT >= 0) {
  120. $bottomlinks[] = array('LinkPath' => $HTTP_DOCUMENT_ROOT.$LIBRARY_DIR.
  121. $LIBRARY_FILE."?SearchTerm=".$sterm."&amp;title=".
  122. $stitle."&amp;author=".$sauth."&amp;description=".$sdesc."&amp;isbn=".
  123. $sisbn."&amp;catnum=".$scatnum."&amp;format=".$sformat."&amp;category=".
  124. $scategory."&amp;keywords=".$skeywords."&amp;lbegin=".($lbegin-$LISTING_LIMIT).
  125. "&amp;scount=".$scount,
  126. 'LinkText' => "<< ".$S_PREVIOUS." ".$LISTING_LIMIT." ".$S_RESULTS);
  127. }
  128. if($lbegin+$LISTING_LIMIT < $scount) {
  129. $linkpath = $HTTP_DOCUMENT_ROOT.$LIBRARY_DIR.
  130. $LIBRARY_FILE."?SearchTerm=".$sterm."&amp;title=".
  131. $stitle."&amp;author=".$sauth."&amp;description=".$sdesc."&amp;isbn=".
  132. $sisbn."&amp;catnum=".$scatnum."&amp;format=".$sformat."&amp;category=".
  133. $scategory."&amp;keywords=".$skeywords."&amp;lbegin=".($lbegin+$LISTING_LIMIT)."&amp;scount=".$scount;
  134. if($scount-($lbegin+$LISTING_LIMIT) < $LISTING_LIMIT) {
  135. $linktext = $S_NEXT." ".($scount-($lbegin+$LISTING_LIMIT))." ".$S_RESULTS." >>";
  136. }
  137. else { $linktext = $S_NEXT." ".$LISTING_LIMIT." ".$S_RESULTS." >>"; }
  138. $bottomlinks[] = array('LinkPath' => $linkpath, 'LinkText' => $linktext);
  139. }
  140. $smarty->assign('bottomlinks',$bottomlinks);
  141. }
  142. else {
  143. $smarty->assign('notice',$N_SEARCH_LIBRARY_NONE);
  144. }
  145. }
  146. else {
  147. if($id != null) {
  148. $value =& $db_lib->GetLibraryData($id);
  149. $cat = $value->Category;
  150. $tblarr = array();
  151. $tblclass = "tbl-listing";
  152. $tbltdclass = array("tbl-listing-title","tbl-listing-item");
  153. $cbdlink = "";
  154. if ($value->ISBN != null) {
  155. $cbdlink = '<a href="http://www.christianbook.com/Christian/Books/easy_find/'.
  156. '139339658?action=Search&amp;Ntk=product.isbn&amp;Ntt='.$value->ISBN.'">'.$S_LIB_CBD_LINK.'</a><br /><br />';
  157. }
  158. $tblheader = " <h2>".$value->Title."</h2>".$cbdlink;
  159.  
  160. if ($value->Author != "") {
  161. array_push($tblarr,array($S_AUTHOR,$value->Author));
  162. }
  163. if ($value->Editor != null) {
  164. array_push($tblarr,array($S_EDITOR,$value->Editor));
  165. }
  166. if ($value->Publisher != null) {
  167. array_push($tblarr,array($S_PUBLISHER,$value->Publisher));
  168. }
  169. if ($value->Series != null) {
  170. array_push($tblarr,array($S_SERIES,$value->Series));
  171. }
  172. if ($value->Description != null) {
  173. array_push($tblarr,array($S_DESC,$value->Description));
  174. }
  175. if ($value->CatalogNumber != null) {
  176. array_push($tblarr,array($S_CATALOG,$value->CatalogNumber));
  177. }
  178. if ($value->ISBN != null) {
  179. array_push($tblarr,array($S_ISBN,$value->ISBN));
  180. }
  181. if ($value->Category != null) {
  182. array_push($tblarr,array($S_CATEGORY,$value->Category));
  183. }
  184. if ($value->Keywords != null) {
  185. array_push($tblarr,array($S_KEYWORDS,$value->Keywords));
  186. }
  187. if ($value->Format != null) {
  188. array_push($tblarr,array($S_FORMAT,$value->Format));
  189. }
  190. if ($value->Year != null) {
  191. array_push($tblarr,array($S_YEAR,$value->Year));
  192. }
  193. if ($value->Pages != null) {
  194. array_push($tblarr,array($S_PAGES,$value->Pages));
  195. }
  196. if ($value->Copies != 0) {
  197. array_push($tblarr,array($S_COPIES,$value->Copies));
  198. }
  199. if ($value->CopiesOut != 0) {
  200. array_push($tblarr,array($S_COPIES_OUT,$value->CopiesOut));
  201. }
  202. if ($value->Notes != null) {
  203. array_push($tblarr,array($S_NOTES,$value->Notes));
  204. }
  205. $smarty->assign('printtable',UtilHtml::createTable($tblarr,$tblheader,$tblclass,"","",$tbltdclass));
  206. }
  207. else if($cat != "") {
  208. $listing = $db_lib->GetLibraryCategoryItems($cat,$LISTING_LIMIT,$lbegin);
  209. if(!$scntflg){$scount = $db_lib->GetLibraryCategoryCount($cat);}
  210. $smarty->assign('heading',$cat." (".$scount." ".$S_TOTAL.")");
  211. if($listing != null) {
  212. $listelements = array();
  213. foreach($listing as $item) {
  214. $linktext = $item->Title." by ";
  215. if($item->Author != "") { $linktext .= $item->Author; }
  216. else if ($item->Editor != "") { $linktext .= $item->Editor; }
  217. else { $linktext .= $item->Publisher; }
  218. $linktext .= " [".$item->CatalogNumber."]";
  219. $listelements[] = array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$LIBRARY_DIR.$LIBRARY_FILE."?id=".$item->ID,
  220. 'Title'=>$linktext);
  221. }
  222. $smarty->assign('listelements',$listelements);
  223. $bottomlinks = array();
  224. if($scount >= $lbegin-$LISTING_LIMIT && $lbegin-$LISTING_LIMIT >= 0) {
  225. $bottomlinks[] = array('LinkPath' => $HTTP_DOCUMENT_ROOT.$LIBRARY_DIR.
  226. $LIBRARY_FILE."?cat=".$cat."&amp;lbegin=".($lbegin-$LISTING_LIMIT).
  227. "&amp;scount=".$scount,
  228. 'LinkText' => "<< ".$S_PREVIOUS." ".$LISTING_LIMIT);
  229. }
  230. if($lbegin+$LISTING_LIMIT < $scount) {
  231. $linkpath = $HTTP_DOCUMENT_ROOT.$LIBRARY_DIR.
  232. $LIBRARY_FILE."?cat=".$cat."&amp;lbegin=".($lbegin+$LISTING_LIMIT).
  233. "&amp;scount=".$scount;
  234. if($scount-($lbegin+$LISTING_LIMIT) < $LISTING_LIMIT) {
  235. $linktext = $S_NEXT." ".($scount-($lbegin+$LISTING_LIMIT))." ".$S_RESULTS." >>";
  236. }
  237. else { $linktext = $S_NEXT." ".$LISTING_LIMIT." ".$S_RESULTS." >>"; }
  238. $bottomlinks[] = array('LinkPath' => $linkpath, 'LinkText' => $linktext);
  239. }
  240. $smarty->assign('bottomlinks',$bottomlinks);
  241. }
  242. else {
  243. $smarty->assign('notice',$N_NO_LIB_FOUND." ".$S_FROM." ".$cat);
  244. }
  245. }
  246. }
  247. }
  248. else {
  249. $smarty->assign('introstatements',array(array('Title'=>$CHURCH_NAME." ".$S_LIBRARY." ".$S_CATALOG,
  250. 'Text'=>$LIBRARY_INTRO)));
  251. }
  252. if($id != null) {
  253. $smarty->assign('returnlink',array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$LIBRARY_DIR.$LIBRARY_FILE."?cat=".$cat,
  254. 'LinkText'=>$S_RETURN_TO." ".$cat));
  255. }
  256. UtilSmarty::displaySectionPage($smarty);
  257. ?>
  258. <?php require_once $SERVER_DIRECTORY.$INCLUDE_PATH.$FOOTER; ?>

Documentation generated on Mon, 10 May 2004 12:10:38 -0700 by phpDocumentor 1.3.0RC3