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

Source for file devotional.php

Documentation is available at devotional.php

  1. <?php
  2. /**
  3. * <b>Devotional</b><br />
  4. * The devotional section shows all of the devotionals and the showcased devotional.
  5. * All devotionals can create a PDF version on the fly.
  6. * This page parses out verse XML:
  7. * <code><verse ver="NKJV">John 3:16</verse><link ver="NIV">John 3:16</link></code>
  8. * @author Kristen O'Brien <kristen_paristemi-com>
  9. * @copyright Copyright 2004, Kristen O'Brien
  10. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11. * @link http://www.paristemi.com Paristemi Main Site
  12. * @package paristemi
  13. * @subpackage paristemi_business_logic
  14. * @since Build 0.5
  15. * @version Build 0.7
  16. * @filesource
  17. */
  18. /**
  19. * Include the constants file and all of the files in the include list
  20. */
  21. if(ltrim(dirname($_SERVER['SCRIPT_FILENAME'])) == "" || !file_exists($_SERVER['DOCUMENT_ROOT']."/constants.php")) {
  22. if(!file_exists("../constants.php")) { require_once("../public_html/constants.php"); }
  23. else { require_once("../constants.php"); }
  24. }
  25. else { require_once($_SERVER['DOCUMENT_ROOT']."/constants.php"); }
  26. foreach($INCLUDE_LIST as $includefile) { require_once $includefile; }
  27. $db = new Database();
  28. $db_main = $db->GetClass('main');
  29. $smarty = UtilSmarty::createSmarty();
  30. $dlpdf = "";$id="";
  31. if(isset($HTTP_GET_VARS['dlpdf'])) {$dlpdf = $HTTP_GET_VARS['dlpdf'];}
  32. if(isset($HTTP_GET_VARS['id'])) {$id = $HTTP_GET_VARS['id'];}
  33. if($dlpdf == "yes" && $id != null) {
  34. $devo =& $db_main->GetDevotional($id);
  35. $text =& UtilBible::ParseVerses($devo->Text);
  36. if($devo->Prayer != null) {
  37. $text .= "\r\n\r\n".$S_PRAYER.": <i>".$devo->Prayer."</i>"; }
  38. UtilFiles::CreatePDF($devo->Title,$text,$S_BY.", ".$devo->AuthorName,
  39. $HTTP_DOCUMENT_ROOT.$DEVOTIONAL_FILE."?id=".$devo->ID);
  40. }
  41. else {
  42. if($id != "") {
  43. $devotional = $db_main->GetDevotional($id);
  44. $pagesubtitle = $devotional->Title;
  45. }
  46. else { $pagesubtitle = ""; }
  47. require_once $HTTP_DOCUMENT_ROOT.$INCLUDE_PATH.$HEADER.
  48. "?pagetitle=".str_replace(" ","%20",htmlentities($S_DEVOTIONALS)).
  49. "&pagesubtitle=".str_replace(" ","%20",htmlentities(stripslashes($pagesubtitle))).
  50. "&pagedesc=".str_replace(" ","%20",htmlentities($CHURCH_NAME." ".$S_DESC_DEVOTIONALS));
  51. $sidesection = array('Title'=>$S_DEVOTIONALS,'Links'=>array());
  52. $devotionals = $db_main->GetAllDevotional($LISTING_LIMIT,0,"D.ID desc ");
  53. foreach($devotionals as $devotional) {
  54. $sidesection['Links'][] = array('LinkPath'=>$HTTP_DOCUMENT_ROOT.
  55. $DEVOTIONAL_FILE."?id=".$devotional->ID,
  56. 'LinkText'=>wordwrap($devotional->Title,30,"<br />"));
  57. }
  58. $sidesection['Links'][] = array('LinkPath'=>"",'LinkText'=>"break");
  59. $scount=0;
  60. if(isset($HTTP_GET_VARS['scount'])) {$scount = $HTTP_GET_VARS['scount'];}
  61. else { $scount = $db_main->GetAllDevotionalCount(); }
  62. if($scount > $LISTING_LIMIT) {
  63. $sidesection['Links'][] = array(
  64. 'LinkPath'=>$HTTP_DOCUMENT_ROOT.$DEVOTIONAL_FILE."?listing=yes",
  65. 'LinkText'=>$S_ALL." ".$S_DEVOTIONALS); }
  66. $smarty->assign('icondescriptions',array(array(
  67. 'src'=>$HTTP_DOCUMENT_ROOT.$IMAGE_PATH.$PDF_IMG,
  68. 'alt'=>"PDF",'desc'=>"PDF")));
  69. $smarty->assign('sidesections',array($sidesection));
  70. if($HTTP_GET_VARS) {
  71. $listing="";$lbegin=0;$scount=0;$scntflg=false;
  72. if(isset($HTTP_GET_VARS['listing'])) {$listing = $HTTP_GET_VARS['listing'];}
  73. if(isset($HTTP_GET_VARS['lbegin'])) {$lbegin = $HTTP_GET_VARS['lbegin'];}
  74. if(isset($HTTP_GET_VARS['scount'])) {$scount = $HTTP_GET_VARS['scount'];$scntflg=true;}
  75. if($id != null) {
  76. $devotional = $db_main->GetDevotional($id);
  77. $smarty->assign('heading',$devotional->Title);
  78. if($SHOW_PDF_DL) {
  79. $smarty->assign('dllink',array(
  80. 'LinkPath'=>$HTTP_DOCUMENT_ROOT.$DEVOTIONAL_FILE."?id=".$devotional->ID."&amp;dlpdf=yes",
  81. 'LinkText'=> $S_DOWNLOAD." ".$S_PRINTABLE_VERSION,
  82. 'IconImage'=>array('src'=>$HTTP_DOCUMENT_ROOT.$IMAGE_PATH.$PDF_IMG,'alt'=>"PDF")));
  83. }
  84. $text = $S_VERSES." ".$S_FOR." ".$S_DEVOTIONAL.": ";
  85. $ref = str_replace(":","%3A",str_replace(" ","+",$devotional->Verses));
  86. $text .= "<a href=\"http://www.biblegateway.com/cgi-bin/bible?passage=".$ref.
  87. "&amp;x=22&amp;y=12&amp;version=".$BIBLE_VERSION."&amp;showfn=no&amp;showxref=no&amp;language=";
  88. $text .= $BIBLE_LANGUAGE."&amp;orientation=linebyline\">".$devotional->Verses."</a>";
  89. $text .= "<br /><br />".nl2br(UtilBible::ParseVerses($devotional->Text));
  90. if($devotional->Prayer) {
  91. $text .= "<br /><br /><span class=\"italics\">".$S_PRAYER.": ".nl2br(UtilBible::ParseVerses($devotional->Prayer))."</span>"; }
  92. $text .= "<br /><br />".$S_WRITTEN." ".$S_BY.": <a href=\"".$GLOBALS['HTTP_DOCUMENT_ROOT'].
  93. $GLOBALS['CONTACT_FORM']."?id=".$devotional->AuthorID."\">".$devotional->AuthorName."</a><br /><br />";
  94. $smarty->assign('text',$text);
  95. }
  96. else if($listing == "yes") {
  97. $devotionals = $db_main->GetAllDevotional($LISTING_LIMIT,$lbegin,"D.ID desc ");
  98. $scount = $db_main->GetAllDevotionalCount();
  99. $smarty->assign('heading',$S_DEVOTIONAL." ".$S_LISTING." (".$scount." ".$S_TOTAL.")");
  100. $listelements = array();
  101. $bottomlinks = array();
  102. foreach($devotionals as $devotional) {
  103. $listelements[] = array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$DEVOTIONAL_FILE."?id=".$devotional->ID,
  104. 'Title'=>$devotional->Title);
  105. }
  106. if($scount >= $lbegin-$LISTING_LIMIT && $lbegin-$LISTING_LIMIT >= 0) {
  107. $bottomlinks[] = array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$DEVOTIONAL_FILE.
  108. "?listing=yes"."&amp;lbegin=".($lbegin-$LISTING_LIMIT).
  109. "&amp;scount=".$scount,'LinkText'=>"&lt;&lt; ".$S_PREVIOUS." ".$LISTING_LIMIT);
  110. }
  111. if($lbegin+$LISTING_LIMIT < $scount) {
  112. if($scount-($lbegin+$LISTING_LIMIT) < $LISTING_LIMIT) {
  113. $linktext = $S_NEXT." ".($scount-($lbegin+$LISTING_LIMIT))." &gt;&gt;";
  114. }
  115. else { $linktext = $S_NEXT." ".$LISTING_LIMIT." &gt;&gt;"; }
  116. $bottomlinks[] = array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$DEVOTIONAL_FILE.
  117. "?listing=yes"."&amp;lbegin=".($lbegin+$LISTING_LIMIT)."&amp;scount=".$scount,'LinkText'=>$linktext);
  118. }
  119. $smarty->assign('listelements',$listelements);
  120. $smarty->assign('bottomlinks',$bottomlinks);
  121. }
  122. }
  123. else {
  124. $devotional = $db_main->GetShowcaseDevotional();
  125. $smarty->assign('heading',$devotional->Title);
  126. if($SHOW_PDF_DL) {
  127. $smarty->assign('dllink',array(
  128. 'LinkPath'=>$HTTP_DOCUMENT_ROOT.$DEVOTIONAL_FILE."?id=".$devotional->ID."&amp;dlpdf=yes",
  129. 'LinkText'=> $S_DOWNLOAD." ".$S_PRINTABLE_VERSION,
  130. 'IconImage'=>array('src'=>$HTTP_DOCUMENT_ROOT.$IMAGE_PATH.$PDF_IMG,'alt'=>"PDF")));
  131. }
  132. $text = $S_VERSES." ".$S_FOR." ".$S_DEVOTIONAL.": ";
  133. $ref = str_replace(":","%3A",str_replace(" ","+",$devotional->Verses));
  134. $text .= "<a href=\"http://www.biblegateway.com/cgi-bin/bible?passage=".$ref.
  135. "&amp;x=22&amp;y=12&amp;version=".$BIBLE_VERSION."&amp;showfn=no&amp;showxref=no&amp;language=";
  136. $text .= $BIBLE_LANGUAGE."&amp;orientation=linebyline\">".$devotional->Verses."</a>";
  137. $text .= "<br /><br />".nl2br(UtilBible::ParseVerses($devotional->Text));
  138. if($devotional->Prayer) {
  139. $text .= "<br /><br /><span class=\"italics\">".$S_PRAYER.": ".nl2br(UtilBible::ParseVerses($devotional->Prayer))."</span>"; }
  140. $text .= "<br /><br />".$S_WRITTEN." ".$S_BY.": <a href=\"".$GLOBALS['HTTP_DOCUMENT_ROOT'].
  141. $GLOBALS['CONTACT_FORM']."?id=".$devotional->AuthorID."\">".$devotional->AuthorName."</a><br /><br />";
  142. $smarty->assign('text',$text);
  143. }
  144. $smarty->assign('bottomnote',$S_NOTE_PDF);
  145. UtilSmarty::displaySectionPage($smarty);
  146. require_once $SERVER_DIRECTORY.$INCLUDE_PATH.$FOOTER;
  147. }
  148. ?>

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