PageRenderTime 73ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/sermon-browser/sb-includes/sb-install.php

https://github.com/Jarrod-Williams/Sermons-Browser-Plugin
PHP | 515 lines | 447 code | 59 blank | 9 comment | 20 complexity | d4c9347392a61c52873292f6b6c13f21 MD5 | raw file
  1. <?php
  2. function sb_install() {
  3. global $wpdb;
  4. $sermonUploadDir = sb_get_default('sermon_path');
  5. require (SB_INCLUDES_DIR.'/dictionary.php');
  6. if (!is_dir(SB_ABSPATH.$sermonUploadDir))
  7. sb_mkdir(SB_ABSPATH.$sermonUploadDir);
  8. if (!is_dir(SB_ABSPATH.$sermonUploadDir.'images'))
  9. sb_mkdir(SB_ABSPATH.$sermonUploadDir.'images');
  10. $table_name = "{$wpdb->prefix}sb_preachers";
  11. if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
  12. $sql = "CREATE TABLE {$table_name} (
  13. id INT(10) NOT NULL AUTO_INCREMENT,
  14. name VARCHAR(30) NOT NULL,
  15. description TEXT NOT NULL,
  16. image VARCHAR(255) NOT NULL,
  17. PRIMARY KEY (id)
  18. )";
  19. $wpdb->query ($sql);
  20. $wpdb->query ("INSERT INTO {$table_name} (name, description, image) VALUES ('C H Spurgeon', '', '')");
  21. $wpdb->query ("INSERT INTO {$table_name} (name, description, image) VALUES ('Martyn Lloyd-Jones', '', '')");
  22. }
  23. $table_name = "{$wpdb->prefix}sb_series";
  24. if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
  25. $sql = "CREATE TABLE {$table_name} (
  26. id INT(10) NOT NULL AUTO_INCREMENT,
  27. name VARCHAR(255) NOT NULL,
  28. page_id INT(10) NOT NULL,
  29. PRIMARY KEY (id)
  30. )";
  31. $wpdb->query ($sql);
  32. $wpdb->query ("INSERT INTO {$table_name} (name, page_id) VALUES ('Exposition of the Psalms', 0)");
  33. $wpdb->query ("INSERT INTO {$table_name} (name, page_id) VALUES ('Exposition of Romans', 0)");
  34. }
  35. $table_name = "{$wpdb->prefix}sb_services";
  36. if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
  37. $sql = "CREATE TABLE {$table_name} (
  38. id INT(10) NOT NULL AUTO_INCREMENT,
  39. name VARCHAR(255) NOT NULL,
  40. time VARCHAR(5) NOT NULL,
  41. PRIMARY KEY (id)
  42. )";
  43. $wpdb->query ($sql);
  44. $wpdb->query ("INSERT INTO {$table_name} (name, time) VALUES ('Sunday Morning', '10:30')");
  45. $wpdb->query ("INSERT INTO {$table_name} (name, time) VALUES ('Sunday Evening', '18:00')");
  46. $wpdb->query ("INSERT INTO {$table_name} (name, time) VALUES ('Midweek Meeting', '19:00')");
  47. $wpdb->query ("INSERT INTO {$table_name} (name, time) VALUES ('Special event', '20:00')");
  48. }
  49. $table_name = "{$wpdb->prefix}sb_sermons";
  50. if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
  51. $sql = "CREATE TABLE {$table_name} (
  52. id INT(10) NOT NULL AUTO_INCREMENT,
  53. title VARCHAR(255) NOT NULL,
  54. preacher_id INT(10) NOT NULL,
  55. datetime DATETIME NOT NULL,
  56. service_id INT(10) NOT NULL,
  57. series_id INT(10) NOT NULL,
  58. start TEXT NOT NULL,
  59. end TEXT NOT NULL,
  60. description TEXT,
  61. time VARCHAR (5),
  62. override TINYINT (1),
  63. page_id INT(10) NOT NULL,
  64. PRIMARY KEY (id)
  65. )";
  66. $wpdb->query ($sql);
  67. }
  68. $table_name = "{$wpdb->prefix}sb_books_sermons";
  69. if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
  70. $sql = "CREATE TABLE {$table_name} (
  71. id INT(10) NOT NULL AUTO_INCREMENT,
  72. book_name VARCHAR(30) NOT NULL,
  73. chapter INT(10) NOT NULL,
  74. verse INT(10) NOT NULL,
  75. `order` INT(10) NOT NULL,
  76. type VARCHAR (30) DEFAULT NULL,
  77. sermon_id INT(10) NOT NULL,
  78. PRIMARY KEY (id),
  79. KEY sermon_id (sermon_id)
  80. )";
  81. $wpdb->query ($sql);
  82. }
  83. $table_name = "{$wpdb->prefix}sb_books";
  84. if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
  85. $sql = "CREATE TABLE {$table_name} (
  86. id INT(10) NOT NULL AUTO_INCREMENT,
  87. name VARCHAR(30) NOT NULL,
  88. PRIMARY KEY (id)
  89. )";
  90. $wpdb->query ($sql);
  91. }
  92. $table_name = "{$wpdb->prefix}sb_stuff";
  93. if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
  94. $sql = "CREATE TABLE {$table_name} (
  95. id INT(10) NOT NULL AUTO_INCREMENT ,
  96. type VARCHAR(30) NOT NULL,
  97. name TEXT NOT NULL,
  98. sermon_id INT(10) NOT NULL,
  99. count INT(10) NOT NULL,
  100. duration VARCHAR (6) NOT NULL,
  101. PRIMARY KEY (id)
  102. )";
  103. $wpdb->query ($sql);
  104. }
  105. $table_name = "{$wpdb->prefix}sb_tags";
  106. if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
  107. $sql = "CREATE TABLE {$table_name} (
  108. id int(10) NOT NULL auto_increment,
  109. name varchar(255) default NULL,
  110. PRIMARY KEY (id),
  111. UNIQUE KEY name (name)
  112. )";
  113. $wpdb->query ($sql);
  114. }
  115. $table_name = "{$wpdb->prefix}sb_sermons_tags";
  116. if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
  117. $sql = "CREATE TABLE {$table_name} (
  118. id INT(10) NOT NULL AUTO_INCREMENT,
  119. sermon_id INT(10) NOT NULL,
  120. tag_id INT(10) NOT NULL,
  121. INDEX (sermon_id),
  122. PRIMARY KEY (id)
  123. )";
  124. $wpdb->query ($sql);
  125. }
  126. sb_update_option('upload_dir', $sermonUploadDir);
  127. sb_update_option('upload_url', sb_get_default('attachment_url'));
  128. sb_update_option('podcast_url', site_url().'?podcast');
  129. sb_update_option('display_method', 'dynamic');
  130. sb_update_option('sermons_per_page', '10');
  131. sb_update_option('search_template', sb_default_multi_template());
  132. sb_update_option('single_template', sb_default_single_template());
  133. sb_update_option('css_style', sb_default_css());
  134. sb_update_option('style_date_modified', strtotime('now'));
  135. sb_update_option('search_output', strtr(sb_default_multi_template(), sb_search_results_dictionary()));
  136. sb_update_option('single_output', strtr(sb_default_single_template(), sb_sermon_page_dictionary()));
  137. $books = sb_get_default('bible_books');
  138. foreach ($books as $book)
  139. $wpdb->query("INSERT INTO {$wpdb->prefix}sb_books VALUES (null, '{$book}')");
  140. sb_update_option('db_version', SB_DATABASE_VERSION);
  141. sb_update_option('filter_type', 'oneclick');
  142. sb_update_option('filter_hide', 'hide');
  143. sb_update_option('import_prompt',true);
  144. sb_update_option('hide_no_attachments',false);
  145. sb_update_option('import_title', false);
  146. sb_update_option('import_artist', false);
  147. sb_update_option('import_album', false);
  148. sb_update_option('import_comments', false);
  149. sb_update_option('import_filename', 'none');
  150. sb_update_option('mp3_shortcode', '[audio:%SERMONURL%]');
  151. }
  152. //Default template for search results
  153. function sb_default_multi_template () {
  154. $multi = <<<HERE
  155. <div class="sermon-browser">
  156. [filters_form]
  157. <div class="clear">
  158. <h4>Subscribe to Podcast</h4>
  159. <table class="podcast">
  160. <tr>
  161. <td class="podcastall">
  162. <table>
  163. <tr>
  164. <td class="podcast-icon"><a href="[podcast]">[podcasticon]</a></td>
  165. <td><strong>All sermons</strong><br /><a href="[itunes_podcast]">iTunes</a> &bull; <a href="[podcast]">Other</a></td>
  166. </tr>
  167. </table>
  168. <td style="width: 2em"> </td>
  169. <td class="podcastcustom">
  170. <table>
  171. <tr>
  172. <td class="podcast-icon"><a href="[podcast_for_search]">[podcasticon_for_search]</a></td>
  173. <td><strong>Filtered sermons</strong><br /><a href="[itunes_podcast_for_search]">iTunes</a> &bull; <a href="[podcast_for_search]">Other</a></td>
  174. </tr>
  175. </table>
  176. </td>
  177. </tr>
  178. </table>
  179. </div>
  180. <h2 class="clear">Sermons ([sermons_count])</h2>
  181. <div class="floatright">[next_page]</div>
  182. <div class="floatleft">[previous_page]</div>
  183. <table class="sermons">
  184. [sermons_loop]
  185. <tr>
  186. <td class="sermon-title">[sermon_title]</td>
  187. </tr>
  188. <tr>
  189. <td class="sermon-passage">[first_passage] (Part of the [series_link] series).</td>
  190. </tr>
  191. <tr>
  192. <td class="files">[files_loop][file][/files_loop]</td>
  193. </tr>
  194. <tr>
  195. <td class="embed">[embed_loop][embed][/embed_loop]</td>
  196. </tr>
  197. <tr>
  198. <td class="preacher">Preached by [preacher_link] on [date] ([service_link]). [editlink]</td>
  199. </tr>
  200. [/sermons_loop]
  201. </table>
  202. <div class="floatright">[next_page]</div>
  203. <div class="floatleft">[previous_page]</div>
  204. [creditlink]
  205. </div>
  206. HERE;
  207. return $multi;
  208. }
  209. //Default template for single sermon page
  210. function sb_default_single_template () {
  211. $single = <<<HERE
  212. <div class="sermon-browser-results">
  213. <h2>[sermon_title] <span class="scripture">([passages_loop][passage][/passages_loop])</span> [editlink]</h2>
  214. [preacher_image]<span class="preacher">[preacher_link], [date]</span><br />
  215. Part of the [series_link] series, preached at a [service_link] service<br />
  216. <div class="sermon-description">[sermon_description]</div>
  217. <p class="sermon-tags">Tags: [tags]</p>
  218. [files_loop]
  219. [file_with_download]
  220. [/files_loop]
  221. [embed_loop]
  222. <br />[embed]<br />
  223. [/embed_loop]
  224. [preacher_description]
  225. <table class="nearby-sermons">
  226. <tr>
  227. <th class="earlier">Earlier:</th>
  228. <th>Same day:</th>
  229. <th class="later">Later:</th>
  230. </tr>
  231. <tr>
  232. <td class="earlier">[prev_sermon]</td>
  233. <td>[sameday_sermon]</td>
  234. <td class="later">[next_sermon]</td>
  235. </tr>
  236. </table>
  237. [esvtext]
  238. [creditlink]
  239. </div>
  240. HERE;
  241. return $single;
  242. }
  243. //Default CSS
  244. function sb_default_css () {
  245. $css = <<<HERE
  246. .sermon-browser h2 {
  247. clear: both;
  248. }
  249. #content div.sermon-browser table, #content div.sermon-browser td {
  250. border-top: none;
  251. border-bottom: none;
  252. border-left: none;
  253. border-right: none;
  254. }
  255. #content div.sermon-browser tr td {
  256. padding: 4px 0;
  257. }
  258. #content div.sermon-browser table.podcast table {
  259. margin: 0 1em;
  260. }
  261. #content div.sermon-browser td.sermon-title, #content div.sermon-browser td.sermon-passage {
  262. font-family: "Helvetica Neue",Arial,Helvetica,"Nimbus Sans L",sans-serif;
  263. }
  264. div.sermon-browser table.sermons {
  265. width: 100%;
  266. clear:both;
  267. }
  268. #content div.sermon-browser table.sermons td.sermon-title {
  269. font-weight:bold;
  270. font-size: 140%;
  271. padding-top: 2em;
  272. }
  273. div.sermon-browser table.sermons td.sermon-passage {
  274. font-weight:bold;
  275. font-size: 110%;
  276. }
  277. #content div.sermon-browser table.sermons td.preacher {
  278. border-bottom: 1px solid #444444;
  279. padding-bottom: 1em;
  280. }
  281. div.sermon-browser table.sermons td.files img {
  282. border: none;
  283. margin-right: 24px;
  284. }
  285. table.sermonbrowser td.fieldname {
  286. font-weight:bold;
  287. padding-right: 10px;
  288. vertical-align:bottom;
  289. }
  290. table.sermonbrowser td.field input, table.sermonbrowser td.field select{
  291. width: 170px;
  292. }
  293. table.sermonbrowser td.field #date, table.sermonbrowser td.field #enddate {
  294. width: 150px;
  295. }
  296. table.sermonbrowser td {
  297. white-space: nowrap;
  298. padding-top: 5px;
  299. padding-bottom: 5px;
  300. }
  301. table.sermonbrowser td.rightcolumn {
  302. padding-left: 10px;
  303. }
  304. div.sermon-browser div.floatright {
  305. float: right
  306. }
  307. div.sermon-browser div.floatleft {
  308. float: left
  309. }
  310. img.sermon-icon , img.site-icon {
  311. border: none;
  312. }
  313. table.podcast {
  314. margin: 0 0 1em 0;
  315. }
  316. .podcastall {
  317. float:left;
  318. background: #fff0c8 url(wp-content/plugins/sermon-browser/sb-includes/icons/podcast_background.png) repeat-x;
  319. padding: 0.5em;
  320. font-size: 1em;
  321. -moz-border-radius: 7px;
  322. -webkit-border-radius: 7px;
  323. }
  324. .podcastcustom {
  325. float:right;
  326. background: #fce4ff url(wp-content/plugins/sermon-browser/sb-includes/icons/podcast_custom_background.png) repeat-x;
  327. padding: 0.5em;
  328. font-size: 1em;
  329. -moz-border-radius: 7px;
  330. -webkit-border-radius: 7px;
  331. }
  332. td.podcast-icon {
  333. padding-right:1em;
  334. }
  335. div.filtered, div.mainfilter {
  336. text-align: left;
  337. }
  338. div.filter {
  339. margin-bottom: 1em;
  340. }
  341. .filter-heading {
  342. font-weight: bold;
  343. }
  344. div.sermon-browser-results span.preacher {
  345. font-size: 120%;
  346. }
  347. div.sermon-browser-results span.scripture {
  348. font-size: 80%;
  349. }
  350. div.sermon-browser-results img.preacher {
  351. float:right;
  352. margin-left: 1em;
  353. }
  354. div.sermon-browser-results div.preacher-description {
  355. margin-top: 0.5em;
  356. }
  357. div.sermon-browser-results div.preacher-description span.about {
  358. font-weight: bold;
  359. font-size: 120%;
  360. }
  361. span.chapter-num {
  362. font-weight: bold;
  363. font-size: 150%;
  364. }
  365. span.verse-num {
  366. vertical-align:super;
  367. line-height: 1em;
  368. font-size: 65%;
  369. }
  370. div.esv span.small-caps {
  371. font-variant: small-caps;
  372. }
  373. div.net p.poetry {
  374. font-style: italics;
  375. margin: 0
  376. }
  377. div.sermon-browser #poweredbysermonbrowser {
  378. text-align:center;
  379. }
  380. div.sermon-browser-results #poweredbysermonbrowser {
  381. text-align:right;
  382. }
  383. table.nearby-sermons {
  384. width: 100%;
  385. clear:both;
  386. }
  387. table.nearby-sermons td, table.nearby-sermons th {
  388. text-align: center;
  389. }
  390. table.nearby-sermons .earlier {
  391. padding-right: 1em;
  392. text-align: left;
  393. }
  394. table.nearby-sermons .later {
  395. padding-left: 1em;
  396. text-align:right;
  397. }
  398. table.nearby-sermons td {
  399. width: 33%;
  400. vertical-align: top;
  401. }
  402. ul.sermon-widget {
  403. list-style-type:none;
  404. margin:0;
  405. padding: 0;
  406. }
  407. ul.sermon-widget li {
  408. list-style-type:none;
  409. margin:0;
  410. padding: 0.25em 0;
  411. }
  412. ul.sermon-widget li span.sermon-title {
  413. font-weight:bold;
  414. }
  415. p.audioplayer_container {
  416. display:inline !important;
  417. }
  418. div.sb_edit_link {
  419. display:inline;
  420. }
  421. h2 div.sb_edit_link {
  422. font-size: 80%;
  423. }
  424. .clear {
  425. clear:both;
  426. }
  427. HERE;
  428. return $css;
  429. }
  430. function sb_default_excerpt_template () {
  431. $multi = <<<HERE
  432. <div class="sermon-browser">
  433. <table class="sermons">
  434. [sermons_loop]
  435. <tr>
  436. <td class="sermon-title">[sermon_title]</td>
  437. </tr>
  438. <tr>
  439. <td class="sermon-passage">[first_passage] (Part of the [series_link] series).</td>
  440. </tr>
  441. <tr>
  442. <td class="files">[files_loop][file][/files_loop]</td>
  443. </tr>
  444. <tr>
  445. <td class="embed">[embed_loop][embed][/embed_loop]</td>
  446. </tr>
  447. <tr>
  448. <td class="preacher">Preached by [preacher_link] on [date] ([service_link]).</td>
  449. </tr>
  450. [/sermons_loop]
  451. </table>
  452. </div>
  453. HERE;
  454. return $multi;
  455. }
  456. ?>