/application/controllers/feed.php

https://github.com/brownjohnf/Peace-Corps-App · PHP · 223 lines · 152 code · 47 blank · 24 comment · 0 complexity · 8c49b12ae74afa047d3ad15cee8ea373 MD5 · raw file

  1. <?php
  2. # Copyright (c) 2011, John F. Brown This file is
  3. # licensed under the Affero General Public License version 3 or later. See
  4. # the COPYRIGHT file.
  5. class Feed extends MY_Controller {
  6. function __construct() {
  7. parent::__construct();
  8. $this->load->library(array('page_class', 'common_class', 'tag_class', 'casestudy_class', 'blog_class', 'document_class', 'link_class', 'video_class'));
  9. }
  10. public function index()
  11. {
  12. //redirect('feed/page');
  13. $pages = $this->page_class->feed();
  14. $blogs = $this->blog_class->feed();
  15. $cs = $this->casestudy_class->feed();
  16. $docs = $this->document_class->feed();
  17. $links = $this->link_class->feed();
  18. $vids = $this->video_class->feed();
  19. //echo '<pre>'; echo print_r($feed['data']); echo '</pre>';
  20. $feed = $pages + $blogs + $cs + $docs + $links + $vids;
  21. //print_r($data['feed']);
  22. krsort($feed);
  23. //print_r($data['feed']);
  24. $chunks = array_chunk($feed, 10, true);
  25. $data['feed'] = $chunks[0];
  26. // retrieve tags w/o optional sorting/filter
  27. $tags['tags'] = $this->tag_class->cloud();
  28. $data['backtrack'] = array('feed' => 'Feed');
  29. $this->load->view('head', array('page_title' => 'Updates', 'stylesheets' => array('layout_outer.css', 'layout_inner.css', 'theme.css')));
  30. $this->load->view('header');
  31. $this->load->view('main_open');
  32. $this->load->view('left_column');
  33. $this->load->view('right_column', $tags);
  34. $this->load->view('feed_view', $data);
  35. $this->load->view('main_close');
  36. $this->load->view('footer');
  37. }
  38. public function blog()
  39. {
  40. $this->load->library('blog_class');
  41. $blogs = $this->blog_class->feed();
  42. //echo '<pre>'; echo print_r($feed['data']); echo '</pre>';
  43. krsort($blogs);
  44. $blogs_chunks = array_chunk($blogs, 10, true);
  45. $data['feed'] = $blogs_chunks[0];
  46. // retrieve tags w/o optional sorting/filter
  47. $tags['tags'] = $this->tag_class->cloud();
  48. $data['backtrack'] = array('feed' => 'Feed', 'feed/blog' => 'Blogs');
  49. $this->load->view('head', array('page_title' => 'Recently Updated Blogs', 'stylesheets' => array('layout_outer.css', 'layout_inner.css', 'theme.css'), 'scripts' => array('basic.js', 'jquery.url.js')));
  50. $this->load->view('header');
  51. $this->load->view('main_open');
  52. $this->load->view('left_column');
  53. $this->load->view('right_column', $tags);
  54. $this->load->view('feed_view', $data);
  55. $this->load->view('main_close');
  56. $this->load->view('footer', array('footer' => 'Footer Here'));
  57. }
  58. public function document()
  59. {
  60. $docs = $this->document_class->feed();
  61. //echo '<pre>'; echo print_r($feed['data']); echo '</pre>';
  62. krsort($docs);
  63. $chunks = array_chunk($docs, 10, true);
  64. $data['feed'] = $chunks[0];
  65. // retrieve tags w/o optional sorting/filter
  66. $tags['tags'] = $this->tag_class->cloud();
  67. $data['backtrack'] = array('feed' => 'Feed', 'feed/document' => 'Documents');
  68. $this->load->view('head', array('page_title' => 'Recently Updated Documents', 'stylesheets' => array('layout_outer.css', 'layout_inner.css', 'theme.css')));
  69. $this->load->view('header');
  70. $this->load->view('main_open');
  71. $this->load->view('left_column');
  72. $this->load->view('right_column', $tags);
  73. $this->load->view('feed_view', $data);
  74. $this->load->view('main_close');
  75. $this->load->view('footer');
  76. }
  77. public function link()
  78. {
  79. $feed = $this->link_class->feed();
  80. //echo '<pre>'; echo print_r($feed['data']); echo '</pre>';
  81. krsort($feed);
  82. $chunks = array_chunk($feed, 10, true);
  83. $data['feed'] = $chunks[0];
  84. // retrieve tags w/o optional sorting/filter
  85. $tags['tags'] = $this->tag_class->cloud();
  86. $data['backtrack'] = array('feed' => 'Feed', 'feed/link' => 'Links');
  87. $this->load->view('head', array('page_title' => 'Recently Updated Documents', 'stylesheets' => array('layout_outer.css', 'layout_inner.css', 'theme.css')));
  88. $this->load->view('header');
  89. $this->load->view('main_open');
  90. $this->load->view('left_column');
  91. $this->load->view('right_column', $tags);
  92. $this->load->view('feed_view', $data);
  93. $this->load->view('main_close');
  94. $this->load->view('footer');
  95. }
  96. public function page()
  97. {
  98. $data['feed'] = $this->page_class->feed();
  99. //echo '<pre>'; echo print_r($feed['data']); echo '</pre>';
  100. // retrieve tags w/o optional sorting/filter
  101. $tags['tags'] = $this->tag_class->cloud();
  102. $data['backtrack'] = array('feed' => 'Feed', 'feed/page' => 'Pages');
  103. $this->load->view('head', array('page_title' => 'Page Updates', 'stylesheets' => array('layout_outer.css', 'layout_inner.css', 'theme.css'), 'scripts' => array('basic.js', 'jquery.url.js')));
  104. $this->load->view('header');
  105. $this->load->view('main_open');
  106. $this->load->view('left_column');
  107. $this->load->view('right_column', $tags);
  108. $this->load->view('feed_view', $data);
  109. $this->load->view('main_close');
  110. $this->load->view('footer');
  111. }
  112. public function casestudy()
  113. {
  114. $data['feed'] = $this->casestudy_class->feed();
  115. //echo '<pre>'; echo print_r($feed['data']); echo '</pre>';
  116. // retrieve tags w/o optional sorting/filter
  117. $tags['tags'] = $this->tag_class->cloud();
  118. $data['backtrack'] = array('feed' => 'Feed', 'feed/casestudy' => 'Case Studies');
  119. $this->load->view('head', array('page_title' => 'Case Study Updates', 'stylesheets' => array('layout_outer.css', 'layout_inner.css', 'theme.css'), 'scripts' => array('basic.js', 'jquery.url.js')));
  120. $this->load->view('header');
  121. $this->load->view('main_open');
  122. $this->load->view('left_column');
  123. $this->load->view('right_column', $tags);
  124. $this->load->view('feed_view', $data);
  125. $this->load->view('main_close');
  126. $this->load->view('footer', array('footer' => 'Footer Here'));
  127. }
  128. public function profile()
  129. {
  130. $data['feed'] = $this->page_class->feed();
  131. //echo '<pre>'; echo print_r($feed['data']); echo '</pre>';
  132. // retrieve tags w/o optional sorting/filter
  133. $tags['tags'] = $this->tag_class->cloud();
  134. $data['backtrack'] = array('feed' => 'Feed', 'feed/page' => 'Pages');
  135. $this->load->view('head', array('page_title' => 'Page Updates', 'stylesheets' => array('layout_outer.css', 'layout_inner.css', 'theme.css'), 'scripts' => array('basic.js', 'jquery.url.js')));
  136. $this->load->view('header');
  137. $this->load->view('main_open');
  138. $this->load->view('left_column');
  139. $this->load->view('right_column', $tags);
  140. $this->load->view('feed_view', $data);
  141. $this->load->view('main_close');
  142. $this->load->view('footer');
  143. }
  144. public function tag()
  145. {
  146. $data['feed'] = $this->tag_class->feed(urldecode($this->uri->segment(3)));
  147. //echo '<pre>'; echo print_r($data); echo '</pre>';
  148. // retrieve tags w/o optional sorting/filter
  149. $tags['tags'] = $this->tag_class->cloud();
  150. $data['backtrack'] = array('feed' => 'Feed', 'feed/tag' => 'Tags');
  151. $this->load->view('head', array('page_title' => 'Tag Updates', 'stylesheets' => array('layout_outer.css', 'layout_inner.css', 'theme.css')));
  152. $this->load->view('header');
  153. $this->load->view('main_open');
  154. $this->load->view('left_column');
  155. $this->load->view('right_column', $tags);
  156. $this->load->view('feed_view', $data);
  157. $this->load->view('main_close');
  158. $this->load->view('footer');
  159. }
  160. public function video()
  161. {
  162. $data['feed'] = $this->video_class->feed();
  163. //echo '<pre>'; echo print_r($feed['data']); echo '</pre>';
  164. // retrieve tags w/o optional sorting/filter
  165. $tags['tags'] = $this->tag_class->cloud();
  166. $data['backtrack'] = array('feed' => 'Feed', 'feed/video' => 'Videos');
  167. $this->load->view('head', array('page_title' => 'Case Study Updates', 'stylesheets' => array('layout_outer.css', 'layout_inner.css', 'theme.css')));
  168. $this->load->view('header');
  169. $this->load->view('main_open');
  170. $this->load->view('left_column');
  171. $this->load->view('right_column', $tags);
  172. $this->load->view('feed_view', $data);
  173. $this->load->view('main_close');
  174. $this->load->view('footer');
  175. }
  176. }