- <?php
- /**
- * <b>Devotional</b><br />
- * The devotional section shows all of the devotionals and the showcased devotional.
- * All devotionals can create a PDF version on the fly.
- * This page parses out verse XML:
- * <code><verse ver="NKJV">John 3:16</verse><link ver="NIV">John 3:16</link></code>
- * @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.5
- * @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_main = $db->GetClass('main');
- $smarty = UtilSmarty::createSmarty();
-
- $dlpdf = "";$id="";
- if(isset($HTTP_GET_VARS['dlpdf'])) {$dlpdf = $HTTP_GET_VARS['dlpdf'];}
- if(isset($HTTP_GET_VARS['id'])) {$id = $HTTP_GET_VARS['id'];}
- if($dlpdf == "yes" && $id != null) {
- $devo =& $db_main->GetDevotional($id);
- $text =& UtilBible::ParseVerses($devo->Text);
- if($devo->Prayer != null) {
- $text .= "\r\n\r\n".$S_PRAYER.": <i>".$devo->Prayer."</i>"; }
- UtilFiles::CreatePDF($devo->Title,$text,$S_BY.", ".$devo->AuthorName,
- $HTTP_DOCUMENT_ROOT.$DEVOTIONAL_FILE."?id=".$devo->ID);
- }
- else {
- if($id != "") {
- $devotional = $db_main->GetDevotional($id);
- $pagesubtitle = $devotional->Title;
- }
- else { $pagesubtitle = ""; }
-
- require_once $HTTP_DOCUMENT_ROOT.$INCLUDE_PATH.$HEADER.
- "?pagetitle=".str_replace(" ","%20",htmlentities($S_DEVOTIONALS)).
- "&pagesubtitle=".str_replace(" ","%20",htmlentities(stripslashes($pagesubtitle))).
- "&pagedesc=".str_replace(" ","%20",htmlentities($CHURCH_NAME." ".$S_DESC_DEVOTIONALS));
-
- $sidesection = array('Title'=>$S_DEVOTIONALS,'Links'=>array());
- $devotionals = $db_main->GetAllDevotional($LISTING_LIMIT,0,"D.ID desc ");
- foreach($devotionals as $devotional) {
- $sidesection['Links'][] = array('LinkPath'=>$HTTP_DOCUMENT_ROOT.
- $DEVOTIONAL_FILE."?id=".$devotional->ID,
- 'LinkText'=>wordwrap($devotional->Title,30,"<br />"));
- }
- $sidesection['Links'][] = array('LinkPath'=>"",'LinkText'=>"break");
- $scount=0;
- if(isset($HTTP_GET_VARS['scount'])) {$scount = $HTTP_GET_VARS['scount'];}
- else { $scount = $db_main->GetAllDevotionalCount(); }
- if($scount > $LISTING_LIMIT) {
- $sidesection['Links'][] = array(
- 'LinkPath'=>$HTTP_DOCUMENT_ROOT.$DEVOTIONAL_FILE."?listing=yes",
- 'LinkText'=>$S_ALL." ".$S_DEVOTIONALS); }
- $smarty->assign('icondescriptions',array(array(
- 'src'=>$HTTP_DOCUMENT_ROOT.$IMAGE_PATH.$PDF_IMG,
- 'alt'=>"PDF",'desc'=>"PDF")));
- $smarty->assign('sidesections',array($sidesection));
-
- if($HTTP_GET_VARS) {
- $listing="";$lbegin=0;$scount=0;$scntflg=false;
- if(isset($HTTP_GET_VARS['listing'])) {$listing = $HTTP_GET_VARS['listing'];}
- 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 != null) {
- $devotional = $db_main->GetDevotional($id);
- $smarty->assign('heading',$devotional->Title);
- if($SHOW_PDF_DL) {
- $smarty->assign('dllink',array(
- 'LinkPath'=>$HTTP_DOCUMENT_ROOT.$DEVOTIONAL_FILE."?id=".$devotional->ID."&dlpdf=yes",
- 'LinkText'=> $S_DOWNLOAD." ".$S_PRINTABLE_VERSION,
- 'IconImage'=>array('src'=>$HTTP_DOCUMENT_ROOT.$IMAGE_PATH.$PDF_IMG,'alt'=>"PDF")));
- }
- $text = $S_VERSES." ".$S_FOR." ".$S_DEVOTIONAL.": ";
- $ref = str_replace(":","%3A",str_replace(" ","+",$devotional->Verses));
- $text .= "<a href=\"http://www.biblegateway.com/cgi-bin/bible?passage=".$ref.
- "&x=22&y=12&version=".$BIBLE_VERSION."&showfn=no&showxref=no&language=";
- $text .= $BIBLE_LANGUAGE."&orientation=linebyline\">".$devotional->Verses."</a>";
- $text .= "<br /><br />".nl2br(UtilBible::ParseVerses($devotional->Text));
- if($devotional->Prayer) {
- $text .= "<br /><br /><span class=\"italics\">".$S_PRAYER.": ".nl2br(UtilBible::ParseVerses($devotional->Prayer))."</span>"; }
- $text .= "<br /><br />".$S_WRITTEN." ".$S_BY.": <a href=\"".$GLOBALS['HTTP_DOCUMENT_ROOT'].
- $GLOBALS['CONTACT_FORM']."?id=".$devotional->AuthorID."\">".$devotional->AuthorName."</a><br /><br />";
- $smarty->assign('text',$text);
- }
- else if($listing == "yes") {
- $devotionals = $db_main->GetAllDevotional($LISTING_LIMIT,$lbegin,"D.ID desc ");
- $scount = $db_main->GetAllDevotionalCount();
- $smarty->assign('heading',$S_DEVOTIONAL." ".$S_LISTING." (".$scount." ".$S_TOTAL.")");
- $listelements = array();
- $bottomlinks = array();
- foreach($devotionals as $devotional) {
- $listelements[] = array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$DEVOTIONAL_FILE."?id=".$devotional->ID,
- 'Title'=>$devotional->Title);
- }
- if($scount >= $lbegin-$LISTING_LIMIT && $lbegin-$LISTING_LIMIT >= 0) {
- $bottomlinks[] = array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$DEVOTIONAL_FILE.
- "?listing=yes"."&lbegin=".($lbegin-$LISTING_LIMIT).
- "&scount=".$scount,'LinkText'=>"<< ".$S_PREVIOUS." ".$LISTING_LIMIT);
- }
- if($lbegin+$LISTING_LIMIT < $scount) {
- if($scount-($lbegin+$LISTING_LIMIT) < $LISTING_LIMIT) {
- $linktext = $S_NEXT." ".($scount-($lbegin+$LISTING_LIMIT))." >>";
- }
- else { $linktext = $S_NEXT." ".$LISTING_LIMIT." >>"; }
- $bottomlinks[] = array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$DEVOTIONAL_FILE.
- "?listing=yes"."&lbegin=".($lbegin+$LISTING_LIMIT)."&scount=".$scount,'LinkText'=>$linktext);
- }
- $smarty->assign('listelements',$listelements);
- $smarty->assign('bottomlinks',$bottomlinks);
- }
- }
- else {
- $devotional = $db_main->GetShowcaseDevotional();
- $smarty->assign('heading',$devotional->Title);
- if($SHOW_PDF_DL) {
- $smarty->assign('dllink',array(
- 'LinkPath'=>$HTTP_DOCUMENT_ROOT.$DEVOTIONAL_FILE."?id=".$devotional->ID."&dlpdf=yes",
- 'LinkText'=> $S_DOWNLOAD." ".$S_PRINTABLE_VERSION,
- 'IconImage'=>array('src'=>$HTTP_DOCUMENT_ROOT.$IMAGE_PATH.$PDF_IMG,'alt'=>"PDF")));
- }
- $text = $S_VERSES." ".$S_FOR." ".$S_DEVOTIONAL.": ";
- $ref = str_replace(":","%3A",str_replace(" ","+",$devotional->Verses));
- $text .= "<a href=\"http://www.biblegateway.com/cgi-bin/bible?passage=".$ref.
- "&x=22&y=12&version=".$BIBLE_VERSION."&showfn=no&showxref=no&language=";
- $text .= $BIBLE_LANGUAGE."&orientation=linebyline\">".$devotional->Verses."</a>";
- $text .= "<br /><br />".nl2br(UtilBible::ParseVerses($devotional->Text));
- if($devotional->Prayer) {
- $text .= "<br /><br /><span class=\"italics\">".$S_PRAYER.": ".nl2br(UtilBible::ParseVerses($devotional->Prayer))."</span>"; }
- $text .= "<br /><br />".$S_WRITTEN." ".$S_BY.": <a href=\"".$GLOBALS['HTTP_DOCUMENT_ROOT'].
- $GLOBALS['CONTACT_FORM']."?id=".$devotional->AuthorID."\">".$devotional->AuthorName."</a><br /><br />";
- $smarty->assign('text',$text);
- }
- $smarty->assign('bottomnote',$S_NOTE_PDF);
-
- UtilSmarty::displaySectionPage($smarty);
- require_once $SERVER_DIRECTORY.$INCLUDE_PATH.$FOOTER;
- }
- ?>