diff --git a/application/views/scripts/courses/viewxml.phtml b/application/views/scripts/courses/viewxml.phtml
deleted file mode 100755
index d49df5f5..00000000
--- a/application/views/scripts/courses/viewxml.phtml
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
-
- '.$this->escape($this->title).'
- '.$this->pathAsAbsoluteUrl($this->url()).'
-
- '.date('r').'
- Course Catalog
- http://blogs.law.harvard.edu/tech/rss
-';
-
-$courseIdString = $this->getStringFromOsidId($this->course->getId());
-$catalogIdString = $this->getStringFromOsidId($this->menuCatalogSelectedId);
-print "\n\t\t- ";
-
-print "\n\t\t\t".$this->escape($this->course->getTitle())."";
-
-
-$viewUrl = $this->pathAsAbsoluteUrl($this->url(array('controller' => 'courses', 'action' => 'view', 'catalog' => $catalogIdString, 'course' => $courseIdString)));
-print "\n\t\t\t".$viewUrl."";
-print "\n\t\t\t".$viewUrl."";
-
-print "\n\t\t\tcourse->getDescription();
-print "]]>";
-
-$topicParams = array(
- 'controller' => 'topics',
- 'action' => 'view',
- 'catalog' => $catalogIdString,
-);
-foreach ($this->subjectTopics as $topic) {
- $topicIdString = $this->getStringFromOsidId($topic->getId());
- $topicTypeString = $this->getStringFromOsidType($topic->getGenusType());
- $topicParams['topic'] = $topicIdString;
- print "\n\t\t\tpathAsAbsoluteUrl($this->url($topicParams))."\">";
- print $this->escape($topic->getDisplayName());
- print " ";
-}
-foreach ($this->departmentTopics as $topic) {
- $topicIdString = $this->getStringFromOsidId($topic->getId());
- $topicTypeString = $this->getStringFromOsidType($topic->getGenusType());
- $topicParams['topic'] = $topicIdString;
- print "\n\t\t\tpathAsAbsoluteUrl($this->url($topicParams))."\">";
- print $this->escape($topic->getDisplayName());
- print " ";
-}
-foreach ($this->requirementTopics as $topic) {
- $topicIdString = $this->getStringFromOsidId($topic->getId());
- $topicTypeString = $this->getStringFromOsidType($topic->getGenusType());
- $topicParams['topic'] = $topicIdString;
- print "\n\t\t\tpathAsAbsoluteUrl($this->url($topicParams))."\">";
- print $this->escape($topic->getDisplayName());
- print " ";
-}
-
-if (isset($this->alternates)) {
- $alternateType = new phpkit_type_URNInetType('urn:inet:middlebury.edu:record:alternates');
- while ($this->alternates->hasNext()) {
- try {
- $alternate = $this->alternates->getNextCourse();
- $alternateIdString = $this->getStringFromOsidId($alternate->getId());
- $altParams['course'] = $alternateIdString;
- print "\n\t\t\thasRecordType($alternateType)) {
- $alternateRecord = $alternate->getCourseRecord($alternateType);
- if ($alternateRecord->isPrimary()) {
- print ' is_primary="true"';
- } else {
- print ' is_primary="false"';
- }
- }
- print '>';
- print $this->escape($alternate->getDisplayName());
- print "";
- } catch(osid_NotFoundException $e) {
- }
- }
-}
-
-print $this->render('offeringsxml.phtml');
-
-print "\n\t\t
";
-
-
-?>
-
-
-
diff --git a/application/views/scripts/offeringsxml.phtml b/application/views/scripts/offeringsxml.phtml
deleted file mode 100755
index d8dced08..00000000
--- a/application/views/scripts/offeringsxml.phtml
+++ /dev/null
@@ -1,64 +0,0 @@
-";
-$offeringParams = array(
- 'controller' => 'offerings',
- 'action' => 'view',
- 'course' => null,
- 'topic' => null,
- 'resource' => null
- );
-while ($this->offerings->hasNext()) {
- $offering = $this->offerings->getNextCourseOffering();
- $offeringIdString =$this->getStringFromOsidId($offering->getId());
- if (!isset($currentTerm) || $currentTerm->getId() != $offering->getTermId()) {
- if (isset($currentTerm))
- print "\n\t\t\t\t";
-
- $currentTerm = $offering->getTerm();
- print "\n\t\t\t\tgetStringFromOsidId($currentTerm->getId())."\" name=\"".$this->escape($currentTerm->getDisplayName())."\">";
- }
-
- $offeringParams['offering'] = $offeringIdString;
-
- print "\n\t\t\t\t\t";
- print "\n\t\t\t\t\t\t".$this->escape($offering->getDisplayName())."";
- print "\n\t\t\t\t\t\t".$this->escape($offering->getTitle())."";
- print "\n\t\t\t\t\t\tgetDescription()."]]>";
- $type = $offering->getGenusType();
- print "\n\t\t\t\t\t\tgetStringFromOsidType($type)."\">".$this->escape($type->getDisplayName())."";
- $term = $offering->getTerm();
- print "\n\t\t\t\t\t\tgetStringFromOsidId($term->getId())."\">".$this->escape($term->getDisplayName())."";
- print "\n\t\t\t\t\t\tgetStringFromOsidId($offering->getLocationId())."\">".$this->escape($offering->getLocationInfo())."";
- print "\n\t\t\t\t\t\t".$this->escape($offering->getScheduleInfo())."";
-
- if (!isset($this->hideOfferingInstructors) || !$this->hideOfferingInstructors) {
- if ($offering->hasRecordType($instructorsType)) {
- $instructorsRecord = $offering->getCourseOfferingRecord($instructorsType);
- $instructors = $instructorsRecord->getInstructors();
- if ($instructors->hasNext()) {
- $instNames = array();
- while ($instructors->hasNext()) {
- $instructor = $instructors->getNextResource();
- print "\n\t\t\t\t\t\tgetStringFromOsidId($instructor->getId())."\">";
- if ($instructor->hasRecordType($namesType)) {
- $namesRecord = $instructor->getResourceRecord($namesType);
- print "\n\t\t\t\t\t\t\t".$this->escape($namesRecord->getGivenName()).""; print "\n\t\t\t\t\t\t\t".$this->escape($namesRecord->getSurname())."";
- }
- print "\n\t\t\t\t\t\t\t".$this->escape($instructor->getDisplayName())."";
-
- print "\n\t\t\t\t\t\t";
- }
- }
- }
- }
- print "\n\t\t\t\t\t";
-}
-print "\n\t\t\t\t";
-print "\n\t\t\t";
diff --git a/src/Controller/Courses.php b/src/Controller/Courses.php
index 1df9fe86..04713179 100755
--- a/src/Controller/Courses.php
+++ b/src/Controller/Courses.php
@@ -13,6 +13,7 @@
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
+use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* A controller for working with courses.
@@ -113,6 +114,20 @@ public function view($course, $term = NULL)
}
+ #[Route('/courses/viewxml/{course}/{term}', name: 'view_course_xml')]
+ public function viewxml($course, $term = NULL)
+ {
+ $data = [];
+ $data['courses'] = [$this->getCourseDataByIdString($course, $term)];
+
+ $data['title'] = $data['courses'][0]['course']->getDisplayName();
+ $data['feedLink'] = $this->generateUrl('view_course', ['course' => $course], UrlGeneratorInterface::ABSOLUTE_URL);
+
+ $response = new Response($this->renderView('courses/list.xml.twig', $data));
+ $response->headers->set('Content-Type', 'text/xml; charset=utf-8');
+ return $response;
+ }
+
protected function getCourseDataByIdString($idString, $termIdString = NULL)
{
$id = $this->osidIdMap->fromString($idString);
@@ -182,16 +197,24 @@ protected function getCourseData(\osid_course_Course $course, \osid_course_Term|
$instructorsRecord = $offering->getCourseOfferingRecord($this->instructorsType);
$instructors = $instructorsRecord->getInstructors();
$offering->instructors = [];
+ $offering->instructorNames = [];
if ($instructors->hasNext()) {
- $instNames = array();
while ($instructors->hasNext()) {
$instructor = $instructors->getNextResource();
+ $instructorData = [
+ 'resource' => $instructor,
+ 'givename' => NULL,
+ 'surname' => NULL,
+ ];
if ($instructor->hasRecordType($this->namesType)) {
$namesRecord = $instructor->getResourceRecord($this->namesType);
- $offering->instructors[] = $namesRecord->getSurname();
+ $instructorData['givename'] = $namesRecord->getGivenName();
+ $instructorData['surname'] = $namesRecord->getSurname();
+ $offering->instructorNames[] = $namesRecord->getSurname();
} else {
- $offering->instructors[] = $instructor->getDisplayName();
+ $offering->instructorNames[] = $instructor->getDisplayName();
}
+ $offering->instructors[] = $instructorData;
}
}
}
@@ -202,19 +225,6 @@ protected function getCourseData(\osid_course_Course $course, \osid_course_Term|
return $data;
}
- /**
- * Get an XML view of a course.
- *
- * @return void
- */
- public function viewxmlAction()
- {
- $this->_helper->layout->disableLayout();
- $this->getResponse()->setHeader('Content-Type', 'text.xml');
-
- $this->viewAction();
- }
-
/**
* Search for courses.
*
diff --git a/templates/courses/list.xml.twig b/templates/courses/list.xml.twig
new file mode 100755
index 00000000..0a5b11da
--- /dev/null
+++ b/templates/courses/list.xml.twig
@@ -0,0 +1,15 @@
+
+
+
+ {{ title }}
+ {{ feedLink }}
+
+ {{ 'now' | date('r') }}
+ Course Catalog
+ http://blogs.law.harvard.edu/tech/rss
+{% for course_data in courses %}
+{{ include('partials/course.xml.twig', course_data, with_context = FALSE) }}
+{% endfor %}
+
+
+
diff --git a/templates/partials/course.xml.twig b/templates/partials/course.xml.twig
new file mode 100644
index 00000000..1987121d
--- /dev/null
+++ b/templates/partials/course.xml.twig
@@ -0,0 +1,39 @@
+ -
+ {{ course.displayname }}
+ {{ url('view_course', {'course': osidIdToString(course.id)}) }}
+
+ {{ course.title }}
+ {{ osidIdToString(course.id) }}
+{%~ if is_primary is not null %}
+ {{ is_primary ? 'true':'false' }}
+{% endif ~%}
+{%- if alternates is not empty %}
+{%- for alternate in alternates %}
+ {{ alternate.displayname }}
+{% endfor ~%}
+{% endif %}
+ {{ course.genustype.displayname }}
+{% for topic in subjectTopics %}
+ {{ topic.displayname }}
+{% endfor %}
+{%- for topic in departmentTopics %}
+ {{ topic.displayname }}
+{% endfor %}
+{%- for topic in divisionTopics %}
+ {{ topic.displayname }}
+{% endfor %}
+{%- for topic in requirementTopics %}
+ {{ topic.displayname }}
+{% endfor %}
+{%- if blockTopics is not empty %}
+{%- for topic in blockTopics %}
+ {{ topic.displayname }}
+{% endfor %}
+{% endif %}
+{%- if levelTopics is not empty %}
+{%- for topic in levelTopics %}
+ {{ topic.displayname }}
+{% endfor ~%}
+{% endif %}
+{{ include('partials/offering_list.xml.twig', {offerings: offerings}, with_context = false) }}
+
diff --git a/templates/partials/offering_list.xml.twig b/templates/partials/offering_list.xml.twig
new file mode 100755
index 00000000..3feaeb8f
--- /dev/null
+++ b/templates/partials/offering_list.xml.twig
@@ -0,0 +1,29 @@
+
+{% set currentTerm = null %}
+{% for offering in offerings %}
+{% if currentTerm is null or currentTerm.id != offering.termid %}
+{% if currentTerm is not null %}
+
+{% endif %}
+{% set currentTerm = offering.term %}
+
+{% endif %}
+
+ {{ offering.displayname }}
+ {{ offering.title }}
+
+ {{ offering.genustype.displayname }}
+ {{ offering.term.displayname }}
+ {{ offering.locationInfo }}
+ {{ offering.scheduleinfo }}
+{% for instructor in offering.instructors %}
+
+ {{ instructor.givename }}
+ {{ instructor.surname }}
+ {{ instructor.resource.displayname }}
+
+{% endfor %}
+
+{% endfor %}
+
+
diff --git a/templates/partials/offerings.html.twig b/templates/partials/offerings.html.twig
index 60e62e6d..638bfb0a 100755
--- a/templates/partials/offerings.html.twig
+++ b/templates/partials/offerings.html.twig
@@ -19,8 +19,8 @@
{% endif %}
{{offering.displayname}}
{{ offering.genustype.displayname }}
- {% if offering.instructors %}
- ({{ offering.instructors|join(', ') }})
+ {% if offering.instructorNames %}
+ ({{ offering.instructorNames|join(', ') }})
{% endif %}
{% endfor %}