- <?php
- /**
- * <b>Library Section</b><br />
- * The library section lists the library categories and library catalog items.
- * This section is searchable.
- * @author Kristen O'Brien <kristen_paristemi-com>
- * @copyright Copyright 2004, Kristen O'Brien
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @link http://www.paristemi.com Paristemi Main Site
- * @package paristemi
- * @subpackage paristemi_business_logic
- * @since Build 0.4
- * @version Build 0.7
- * @filesource
- */
- /**
- * Include the constants file and all of the files in the include list
- */
- if(ltrim(dirname($_SERVER['SCRIPT_FILENAME'])) == "" || !file_exists($_SERVER['DOCUMENT_ROOT']."/constants.php")) {
- if(!file_exists("../constants.php")) { require_once("../public_html/constants.php"); }
- else { require_once("../constants.php"); }
- }
- else { require_once($_SERVER['DOCUMENT_ROOT']."/constants.php"); }
- foreach($INCLUDE_LIST as $includefile) { require_once $includefile; }
-
- $db = new Database();
- $db_lib = $db->GetClass('library');
-
- $id="";$cat="";$group="";$item="";$searchterm="";$stitle="";$sauth="";$lbegin=0;$searchflg=false;
- $sdesc="";$sisbn="";$scatnum="";$sformat="";$scategory="";$skeywords="";$scount=0;$scntflg=false;
- if(getenv("QUERY_STRING")) {
- if(isset($HTTP_GET_VARS['id'])) {$id = $HTTP_GET_VARS['id'];}
- if(isset($HTTP_GET_VARS['cat'])) {$cat = $HTTP_GET_VARS['cat'];}
- if(isset($HTTP_GET_VARS['group'])) {$group = $HTTP_GET_VARS['group'];}
- if(isset($HTTP_GET_VARS['item'])) {$item = $HTTP_GET_VARS['item'];}
- if(isset($HTTP_GET_VARS['SearchTerm'])) {
- $searchterm = $HTTP_GET_VARS['SearchTerm'];$searchflg=true; }
- if(isset($HTTP_GET_VARS['title'])) {$stitle = $HTTP_GET_VARS['title'];}
- if(isset($HTTP_GET_VARS['author'])) {$sauth = $HTTP_GET_VARS['author'];}
- if(isset($HTTP_GET_VARS['description'])) {$sdesc = $HTTP_GET_VARS['description'];}
- if(isset($HTTP_GET_VARS['isbn'])) {$sisbn = $HTTP_GET_VARS['isbn'];}
- if(isset($HTTP_GET_VARS['catnum'])) {$scatnum = $HTTP_GET_VARS['catnum'];}
- if(isset($HTTP_GET_VARS['format'])) {$sformat = $HTTP_GET_VARS['format'];}
- if(isset($HTTP_GET_VARS['category'])) {$scategory = $HTTP_GET_VARS['category'];}
- if(isset($HTTP_GET_VARS['keywords'])) {$skeywords = $HTTP_GET_VARS['keywords'];}
- if(isset($HTTP_GET_VARS['lbegin'])) {$lbegin = $HTTP_GET_VARS['lbegin'];}
- if(isset($HTTP_GET_VARS['scount'])) {$scount = $HTTP_GET_VARS['scount'];$scntflg=true;}
- }
-
- if($id != "") {
- $value =& $db_lib->GetLibraryData($id);
- $pagesubtitle = $S_ITEM." - ".$value->Title; }
- else if($cat != "") { $pagesubtitle = $S_CATEGORY." - ".$cat; }
- else if($searchterm != "") { $pagesubtitle = $S_SEARCH." - ".ucwords(strtolower($searchterm)); }
- else { $pagesubtitle = $S_CATALOG; }
-
- require_once $HTTP_DOCUMENT_ROOT.$INCLUDE_PATH.$HEADER.
- "?pagetitle=".str_replace(" ","%20",htmlentities($S_LIBRARY)).
- "&pagesubtitle=".str_replace(" ","%20",htmlentities(stripslashes($pagesubtitle))).
- "&pagedesc=".str_replace(" ","%20",htmlentities($CHURCH_NAME." ".$S_DESC_LIBRARY));
-
- $smarty = UtilSmarty::createSmarty();
-
- $categories = $db_lib->GetCategoriesUsed();
- $sidesection = array();
- $sidesection['Title'] = $S_LIBRARY." ".$S_CATALOG;
- $sidesection['Links'] = array();
- foreach($categories as $category) {
- $sidesection['Links'][]= array('LinkPath' => $HTTP_DOCUMENT_ROOT.$LIBRARY_DIR.
- $LIBRARY_FILE."?cat=".$category,
- 'LinkText' => $category);
- }
- $smarty->assign('sidesections',array($sidesection));
-
- $smarty->assign('searchformname','librarysearch');
- $smarty->assign('searchformfile',$LIBRARY_FILE);
- $smarty->assign('searchconstraints',
- array(array('name'=>'title','title'=>$S_TITLE),
- array('name'=>'author','title'=>$S_AUTHOR),
- array('name'=>'isbn','title'=>$S_ISBN),
- array('name'=>'catnum','title'=>$S_CATALOG." ".$S_NUMBER),
- array('name'=>'format','title'=>$S_FORMAT),
- array('name'=>'category','title'=>$S_CATEGORY),
- array('name'=>'keywords','title'=>$S_KEYWORDS)));
- $smarty->assign('searchsubmittitle',$S_SEARCH);
- $smarty->assign('bottomnote',$S_NOTE_LIBRARY);
-
- if(getenv("QUERY_STRING")) {
- if($searchflg)
- {
- if($searchterm == "") {
- $finalresults =& $db_lib->GetAllLibraryDataByLimit($LISTING_LIMIT,$lbegin);
- $scount = count($db_lib->GetAllLibraryData());
- }
- else {
- $sterm = $searchterm;
- $atype = array();
- if($stitle != null) { $atype[] = "title"; }
- if($sauth != null) { $atype[] = "author"; }
- if($sdesc != null) { $atype[] = "description"; }
- if($sisbn != null) { $atype[] = "isbn"; }
- if($scatnum != null) { $atype[] = "catnum"; }
- if($sformat != null) { $atype[] = "format"; }
- if($scategory != null) { $atype[] = "category"; }
- if($skeywords != null) { $atype[] = "keywords"; }
-
- $finalresults =& $db_lib->SearchLibrary($searchterm,$atype,$LISTING_LIMIT,$lbegin);
- if(!$scntflg) {$scount = $db_lib->SearchLibraryCount($searchterm,$atype);}
- }
-
- $smarty->assign('heading',$S_SEARCH." ".$S_RESULTS." (".$scount." ".$S_RESULTS.")");
-
- if($finalresults != null) {
- $listelements = array();
- foreach($finalresults as $item) {
- $linktext = $item->Title." by ";
- if($item->Author != "") { $linktext .= $item->Author; }
- else if ($item->Editor != "") { $linktext .= $item->Editor; }
- else { $linktext .= $item->Publisher; }
- $linktext .= " [".$item->CatalogNumber."]";
- $listelements[] = array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$LIBRARY_DIR.$LIBRARY_FILE."?id=".$item->ID,
- 'Title'=>$linktext);
- }
- $smarty->assign('listelements',$listelements);
- $bottomlinks = array();
- if($scount >= $lbegin-$LISTING_LIMIT && $lbegin-$LISTING_LIMIT >= 0) {
- $bottomlinks[] = array('LinkPath' => $HTTP_DOCUMENT_ROOT.$LIBRARY_DIR.
- $LIBRARY_FILE."?SearchTerm=".$sterm."&title=".
- $stitle."&author=".$sauth."&description=".$sdesc."&isbn=".
- $sisbn."&catnum=".$scatnum."&format=".$sformat."&category=".
- $scategory."&keywords=".$skeywords."&lbegin=".($lbegin-$LISTING_LIMIT).
- "&scount=".$scount,
- 'LinkText' => "<< ".$S_PREVIOUS." ".$LISTING_LIMIT." ".$S_RESULTS);
- }
- if($lbegin+$LISTING_LIMIT < $scount) {
- $linkpath = $HTTP_DOCUMENT_ROOT.$LIBRARY_DIR.
- $LIBRARY_FILE."?SearchTerm=".$sterm."&title=".
- $stitle."&author=".$sauth."&description=".$sdesc."&isbn=".
- $sisbn."&catnum=".$scatnum."&format=".$sformat."&category=".
- $scategory."&keywords=".$skeywords."&lbegin=".($lbegin+$LISTING_LIMIT)."&scount=".$scount;
- if($scount-($lbegin+$LISTING_LIMIT) < $LISTING_LIMIT) {
- $linktext = $S_NEXT." ".($scount-($lbegin+$LISTING_LIMIT))." ".$S_RESULTS." >>";
- }
- else { $linktext = $S_NEXT." ".$LISTING_LIMIT." ".$S_RESULTS." >>"; }
- $bottomlinks[] = array('LinkPath' => $linkpath, 'LinkText' => $linktext);
- }
- $smarty->assign('bottomlinks',$bottomlinks);
- }
- else {
- $smarty->assign('notice',$N_SEARCH_LIBRARY_NONE);
- }
- }
-
- else {
- if($id != null) {
- $value =& $db_lib->GetLibraryData($id);
- $cat = $value->Category;
- $tblarr = array();
- $tblclass = "tbl-listing";
- $tbltdclass = array("tbl-listing-title","tbl-listing-item");
- $cbdlink = "";
- if ($value->ISBN != null) {
- $cbdlink = '<a href="http://www.christianbook.com/Christian/Books/easy_find/'.
- '139339658?action=Search&Ntk=product.isbn&Ntt='.$value->ISBN.'">'.$S_LIB_CBD_LINK.'</a><br /><br />';
- }
- $tblheader = " <h2>".$value->Title."</h2>".$cbdlink;
-
- if ($value->Author != "") {
- array_push($tblarr,array($S_AUTHOR,$value->Author));
- }
- if ($value->Editor != null) {
- array_push($tblarr,array($S_EDITOR,$value->Editor));
- }
- if ($value->Publisher != null) {
- array_push($tblarr,array($S_PUBLISHER,$value->Publisher));
- }
- if ($value->Series != null) {
- array_push($tblarr,array($S_SERIES,$value->Series));
- }
- if ($value->Description != null) {
- array_push($tblarr,array($S_DESC,$value->Description));
- }
- if ($value->CatalogNumber != null) {
- array_push($tblarr,array($S_CATALOG,$value->CatalogNumber));
- }
- if ($value->ISBN != null) {
- array_push($tblarr,array($S_ISBN,$value->ISBN));
- }
- if ($value->Category != null) {
- array_push($tblarr,array($S_CATEGORY,$value->Category));
- }
- if ($value->Keywords != null) {
- array_push($tblarr,array($S_KEYWORDS,$value->Keywords));
- }
- if ($value->Format != null) {
- array_push($tblarr,array($S_FORMAT,$value->Format));
- }
- if ($value->Year != null) {
- array_push($tblarr,array($S_YEAR,$value->Year));
- }
- if ($value->Pages != null) {
- array_push($tblarr,array($S_PAGES,$value->Pages));
- }
- if ($value->Copies != 0) {
- array_push($tblarr,array($S_COPIES,$value->Copies));
- }
- if ($value->CopiesOut != 0) {
- array_push($tblarr,array($S_COPIES_OUT,$value->CopiesOut));
- }
- if ($value->Notes != null) {
- array_push($tblarr,array($S_NOTES,$value->Notes));
- }
-
- $smarty->assign('printtable',UtilHtml::createTable($tblarr,$tblheader,$tblclass,"","",$tbltdclass));
- }
- else if($cat != "") {
- $listing = $db_lib->GetLibraryCategoryItems($cat,$LISTING_LIMIT,$lbegin);
- if(!$scntflg){$scount = $db_lib->GetLibraryCategoryCount($cat);}
- $smarty->assign('heading',$cat." (".$scount." ".$S_TOTAL.")");
-
- if($listing != null) {
- $listelements = array();
- foreach($listing as $item) {
- $linktext = $item->Title." by ";
- if($item->Author != "") { $linktext .= $item->Author; }
- else if ($item->Editor != "") { $linktext .= $item->Editor; }
- else { $linktext .= $item->Publisher; }
- $linktext .= " [".$item->CatalogNumber."]";
- $listelements[] = array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$LIBRARY_DIR.$LIBRARY_FILE."?id=".$item->ID,
- 'Title'=>$linktext);
- }
- $smarty->assign('listelements',$listelements);
-
- $bottomlinks = array();
- if($scount >= $lbegin-$LISTING_LIMIT && $lbegin-$LISTING_LIMIT >= 0) {
- $bottomlinks[] = array('LinkPath' => $HTTP_DOCUMENT_ROOT.$LIBRARY_DIR.
- $LIBRARY_FILE."?cat=".$cat."&lbegin=".($lbegin-$LISTING_LIMIT).
- "&scount=".$scount,
- 'LinkText' => "<< ".$S_PREVIOUS." ".$LISTING_LIMIT);
- }
- if($lbegin+$LISTING_LIMIT < $scount) {
- $linkpath = $HTTP_DOCUMENT_ROOT.$LIBRARY_DIR.
- $LIBRARY_FILE."?cat=".$cat."&lbegin=".($lbegin+$LISTING_LIMIT).
- "&scount=".$scount;
- if($scount-($lbegin+$LISTING_LIMIT) < $LISTING_LIMIT) {
- $linktext = $S_NEXT." ".($scount-($lbegin+$LISTING_LIMIT))." ".$S_RESULTS." >>";
- }
- else { $linktext = $S_NEXT." ".$LISTING_LIMIT." ".$S_RESULTS." >>"; }
- $bottomlinks[] = array('LinkPath' => $linkpath, 'LinkText' => $linktext);
- }
- $smarty->assign('bottomlinks',$bottomlinks);
- }
- else {
- $smarty->assign('notice',$N_NO_LIB_FOUND." ".$S_FROM." ".$cat);
- }
- }
- }
- }
- else {
- $smarty->assign('introstatements',array(array('Title'=>$CHURCH_NAME." ".$S_LIBRARY." ".$S_CATALOG,
- 'Text'=>$LIBRARY_INTRO)));
- }
- if($id != null) {
- $smarty->assign('returnlink',array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$LIBRARY_DIR.$LIBRARY_FILE."?cat=".$cat,
- 'LinkText'=>$S_RETURN_TO." ".$cat));
- }
- UtilSmarty::displaySectionPage($smarty);
- ?>
- <?php require_once $SERVER_DIRECTORY.$INCLUDE_PATH.$FOOTER; ?>