/themes/risd_english_ox/courses-feed.php

https://github.com/danielwiener/RISD-English · PHP · 184 lines · 126 code · 36 blank · 22 comment · 21 complexity · f1fc24a99f77c38db6813ec250bbe1ac MD5 · raw file

  1. <?php
  2. /**
  3. * Template Name: XML Feed
  4. *
  5. * Two Column pages for pages that need a wider content column
  6. *
  7. * @package RISD-English
  8. * @subpackage Template
  9. */
  10. $winter_course_titles = array();
  11. $fall_course_titles = array();
  12. $spring_course_titles = array();
  13. get_header(); // Loads the header.php template. ?>
  14. <div class="aside">
  15. <?php get_template_part( 'menu', 'secondary' ); // Loads the menu-secondary.php template. ?>
  16. <?php get_sidebar( 'primary' ); // Loads the sidebar-primary.php template. ?>
  17. </div>
  18. <?php do_atomic( 'before_content' ); // oxygen_before_content ?>
  19. <div class="content-wrap">
  20. <div id="content">
  21. <?php do_atomic( 'open_content' ); // oxygen_open_content ?>
  22. <div class="hfeed">
  23. <?php if ( have_posts() ) : ?>
  24. <?php while ( have_posts() ) : the_post(); ?>
  25. <?php do_atomic( 'before_entry' ); // oxygen_before_entry ?>
  26. <div id="post-<?php the_ID(); ?>" class="<?php hybrid_entry_class(); ?>">
  27. <?php do_atomic( 'open_entry' ); // oxygen_open_entry ?>
  28. <?php echo apply_atomic_shortcode( 'entry_title', '[entry-title]' ); ?>
  29. <div class="entry-content expandingList">
  30. <?php $course_xml = simplexml_load_file(XMLFILE);
  31. foreach($course_xml->children() as $department) {
  32. //if($department->NAME == 'ENGLISH DEPT') {
  33. foreach($department->children() as $course) {
  34. if( $course->COURSENAME != "" && $department->NAME == 'LITERARY ARTS AND STUDIES'){
  35. preg_match("/(\d{4})([A-Z][A-Z])/", $course->COURSETERM, $results);
  36. $course_year = $results[1];
  37. $course_semester = $results[2];
  38. //ENGL-8900 ENGL-8800- E101
  39. $course_numbers = array('E101', '8900', '8800', '8888');
  40. $skip_course_name = preg_match("/ENGL-(.*)-/", $course->COURSENAME, $english_results);
  41. $course_number = $english_results[1];
  42. if (in_array($course_number, $course_numbers)) {
  43. //do nothing
  44. } else {
  45. if ($course_semester == 'FA') {
  46. $fall_courses[] = $course;
  47. $fall_year = $course_year;
  48. } //fall
  49. if ($course_semester =='WS') {
  50. $winter_courses[] = $course;
  51. $winter_year = $course_year;
  52. } //winter
  53. if ($course_semester =='SP') {
  54. $spring_courses[] = $course;
  55. $spring_year = $course_year;
  56. } //spring
  57. }
  58. }
  59. }
  60. }
  61. ?>
  62. <h2>Fall Semester <?php echo $fall_year; ?></h2>
  63. <ul><li>
  64. <?php echo wpautop(get_post_meta($post->ID, "_dw_eng-101-fall", true)); ?>
  65. </li>
  66. <?php // Custom sort on the names of the items:
  67. // usort ($fall_courses, function($a, $b) {
  68. // return strcmp($a->COURSETITLE, $b->COURSETITLE);
  69. //}); ?>
  70. <?php foreach ($fall_courses as $fall_course):
  71. $fall_course_string = (string) $fall_course->COURSETITLE;
  72. if (in_array($fall_course_string, $fall_course_titles) ):
  73. //do nothing
  74. else: ?>
  75. <li>
  76. <a href="#"><?php echo $fall_course->COURSENAME ?> - <strong><?php echo $fall_course->COURSETITLE ?></strong></a>
  77. <div class="cdesc">
  78. <p><?php echo $fall_course->COURSEDESC; ?>
  79. <?php if ($fall_course->COURSECREDITS != ''): ?>
  80. <br><strong>Credits: <?php echo $fall_course->COURSECREDITS ?></strong>
  81. <?php endif ?>
  82. </p>
  83. </div></li>
  84. <?php endif ?>
  85. <?php $fall_course_titles[] = (string) $fall_course->COURSETITLE;?>
  86. <?php endforeach; ?></ul><br />
  87. <h2>Winter Session <?php echo $winter_year; ?></h2>
  88. <?php
  89. // usort ($winter_courses, function($a, $b) {
  90. // return strcmp($a->COURSETITLE, $b->COURSETITLE);
  91. // });
  92. ?>
  93. <ul>
  94. <?php foreach ($winter_courses as $winter_course):
  95. $winter_course_string = (string) $winter_course->COURSETITLE;
  96. if (in_array($winter_course_string, $winter_course_titles) ):
  97. //do nothing
  98. else: ?>
  99. <li>
  100. <a href="#"><?php echo $winter_course->COURSENAME ?> - <strong><?php echo $winter_course->COURSETITLE ?></strong></a>
  101. <div class="cdesc">
  102. <p><?php echo $winter_course->COURSEDESC; ?>
  103. <?php if ($winter_course->COURSECREDITS != ''): ?>
  104. <br><strong>Credits: <?php echo $winter_course->COURSECREDITS ?></strong>
  105. <?php endif ?></p></div></li>
  106. <?php endif ?>
  107. <?php $winter_course_titles[] = (string) $winter_course->COURSETITLE;?>
  108. <?php endforeach;
  109. ?></ul>
  110. <?php //print_r($winter_course_titles); ?>
  111. <br />
  112. <h2>Spring Semester <?php echo $spring_year; ?></h2>
  113. <?php // usort ($spring_courses, function($a, $b) {
  114. // return strcmp($a->COURSETITLE, $b->COURSETITLE);
  115. // }); ?>
  116. <ul>
  117. <li>
  118. <?php echo wpautop(get_post_meta($post->ID, "_dw_eng-101-spring", true)); ?>
  119. </li>
  120. <?php foreach ($spring_courses as $spring_course):
  121. $spring_course_string = (string) $spring_course->COURSETITLE;
  122. if (in_array($spring_course_string, $spring_course_titles) ):
  123. //do nothing
  124. else: ?>
  125. <li>
  126. <a href="#"><?php echo $spring_course->COURSENAME ?> - <strong><?php echo $spring_course->COURSETITLE ?></strong></a>
  127. <div class="cdesc">
  128. <p><?php echo $spring_course->COURSEDESC; ?>
  129. <?php if ($spring_course->COURSECREDITS != ''): ?>
  130. <br><strong>Credits: <?php echo $spring_course->COURSECREDITS ?></strong>
  131. <?php endif ?></p></div></li>
  132. <?php endif ?>
  133. <?php $spring_course_titles[] = (string) $spring_course->COURSETITLE;?>
  134. <?php endforeach; ?>
  135. </ul>
  136. </div><!-- .entry-content -->
  137. <?php echo apply_atomic_shortcode( 'entry_meta', '<div class="entry-meta">[entry-edit-link]</div>' ); ?>
  138. <?php do_atomic( 'close_entry' ); // oxygen_close_entry ?>
  139. </div><!-- .hentry -->
  140. <?php do_atomic( 'after_entry' ); // oxygen_after_entry ?>
  141. <?php do_atomic( 'after_singular' ); // oxygen_after_singular ?>
  142. <?php endwhile; ?>
  143. <?php endif; ?>
  144. </div><!-- .hfeed -->
  145. <?php do_atomic( 'close_content' ); // oxygen_close_content ?>
  146. </div><!-- #content -->
  147. <?php do_atomic( 'after_content' ); // oxygen_after_content ?>
  148. <?php get_footer(); // Loads the footer.php template. ?>