Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Curriculum-Request
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tim Steiner
Curriculum-Request
Commits
7ddaeb3d
Commit
7ddaeb3d
authored
16 years ago
by
Tim Steiner
Browse files
Options
Downloads
Patches
Plain Diff
XML dump of all active courses.
parent
6b3fe6e2
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
application/modules/courses/controllers/PublicViewController.php
+139
-7
139 additions, 7 deletions
...tion/modules/courses/controllers/PublicViewController.php
application/modules/courses/models/CourseModel.php
+21
-5
21 additions, 5 deletions
application/modules/courses/models/CourseModel.php
with
160 additions
and
12 deletions
application/modules/courses/controllers/PublicViewController.php
+
139
−
7
View file @
7ddaeb3d
...
@@ -14,9 +14,143 @@ class Courses_PublicViewController extends App_Controller_Action {
...
@@ -14,9 +14,143 @@ class Courses_PublicViewController extends App_Controller_Action {
*/
*/
public
function
allCoursesAction
()
public
function
allCoursesAction
()
{
{
$layout
=
Zend_Layout
::
getMvcInstance
();
$this
->
_disableLayoutAndView
();
$layout
->
disableLayout
();
$courses
=
Courses_CourseModel
::
findAllActive
();
$this
->
getFrontController
()
->
setParam
(
'noViewRenderer'
,
true
);
$courses
->
orderBy
(
'getCourseCode'
);
$dom
=
new
DOMDocument
(
'1.0'
,
'UTF-8'
);
$dom
->
formatOutput
=
true
;
$root
=
$dom
->
createElement
(
'courses'
);
$dom
->
appendChild
(
$root
);
foreach
(
$courses
as
$course
)
{
$courseNode
=
$dom
->
createElement
(
'course'
);
$courseNode
->
appendChild
(
$dom
->
createElement
(
'title'
,
htmlspecialchars
(
$course
->
getTitle
())));
$crosslistings
=
$course
->
getCrosslistings
();
if
(
count
(
$crosslistings
)
>
0
)
{
$courseCodesNode
=
$dom
->
createElement
(
'courseCodes'
);
$courseNode
->
appendChild
(
$courseCodesNode
);
foreach
(
$crosslistings
as
$crosslisting
)
{
$courseCodeNode
=
$dom
->
createElement
(
'courseCode'
);
$courseCodesNode
->
appendChild
(
$courseCodeNode
);
$courseCodeNode
->
setAttribute
(
'type'
,
$crosslisting
[
'type'
]);
$courseCodeNode
->
appendChild
(
$dom
->
createElement
(
'subject'
,
$crosslisting
[
'subject'
]));
$courseCodeNode
->
appendChild
(
$dom
->
createElement
(
'courseNumber'
,
$crosslisting
[
'courseNumber'
]));
if
(
$crosslisting
[
'courseLetter'
])
{
$courseCodeNode
->
appendChild
(
$dom
->
createElement
(
'courseLetter'
,
$crosslisting
[
'courseLetter'
]));
}
}
}
else
{
continue
;
}
$courseNode
->
appendChild
(
$dom
->
createElement
(
'gradingType'
,
htmlspecialchars
(
$course
->
getGradingType
(),
null
,
'UTF-8'
)));
$courseNode
->
appendChild
(
$dom
->
createElement
(
'dfRemoval'
,
htmlspecialchars
(
$course
->
getDfRemoval
(),
null
,
'UTF-8'
)));
$courseNode
->
appendChild
(
$dom
->
createElement
(
'effectiveSemester'
,
htmlspecialchars
(
$course
->
getEffectiveSemester
(),
null
,
'UTF-8'
)));
if
(
$node
=
$this
->
_getNodeFromHtmlFragment
(
$dom
,
'prerequisite'
,
$course
->
getPrerequisite
()))
{
$courseNode
->
appendChild
(
$node
);
}
if
(
$node
=
$this
->
_getNodeFromHtmlFragment
(
$dom
,
'notes'
,
$course
->
getNotes
()))
{
$courseNode
->
appendChild
(
$node
);
}
if
(
$node
=
$this
->
_getNodeFromHtmlFragment
(
$dom
,
'description'
,
$course
->
getDescription
()))
{
$courseNode
->
appendChild
(
$node
);
}
if
(
count
(
$course
->
getCampuses
())
>
0
)
{
$campusesNode
=
$dom
->
createElement
(
'campuses'
);
$courseNode
->
appendChild
(
$campusesNode
);
foreach
(
$course
->
getCampuses
()
as
$campus
)
{
$campusesNode
->
appendChild
(
$dom
->
createElement
(
'campus'
,
$campus
));
}
}
if
(
count
(
$course
->
getDeliveryMethods
())
>
0
)
{
$deliveryMethodsNode
=
$dom
->
createElement
(
'deliveryMethods'
);
$courseNode
->
appendChild
(
$deliveryMethodsNode
);
foreach
(
$course
->
getDeliveryMethods
()
as
$deliveryMethod
)
{
$deliveryMethodsNode
->
appendChild
(
$dom
->
createElement
(
'deliveryMethod'
,
$deliveryMethod
));
}
}
if
(
count
(
$course
->
getTermsOffered
())
>
0
)
{
$termsOfferedNode
=
$dom
->
createElement
(
'termsOffered'
);
$courseNode
->
appendChild
(
$termsOfferedNode
);
foreach
(
$course
->
getTermsOffered
()
as
$term
)
{
$termsOfferedNode
->
appendChild
(
$dom
->
createElement
(
'term'
,
$term
));
}
}
$activities
=
$course
->
getActivities
();
if
(
count
(
$crosslistings
)
>
0
)
{
$activitiesNode
=
$dom
->
createElement
(
'activities'
);
$courseNode
->
appendChild
(
$activitiesNode
);
foreach
(
$activities
as
$activity
)
{
$activityNode
=
$dom
->
createElement
(
'activity'
);
$activitiesNode
->
appendChild
(
$activityNode
);
$activityNode
->
appendChild
(
$dom
->
createElement
(
'type'
,
$activity
[
'type'
]));
if
(
$activity
[
'hours'
])
{
$activityNode
->
appendChild
(
$dom
->
createElement
(
'hours'
,
$activity
[
'hours'
]));
}
}
}
$credits
=
$course
->
getCredits
();
if
(
count
(
$credits
)
>
0
)
{
$creditsNode
=
$dom
->
createElement
(
'credits'
);
$courseNode
->
appendChild
(
$creditsNode
);
foreach
(
$credits
as
$credit
)
{
$creditNode
=
$dom
->
createElement
(
'credit'
,
$credit
[
'hours'
]);
$creditsNode
->
appendChild
(
$creditNode
);
$creditNode
->
setAttribute
(
'type'
,
$credit
[
'description'
]);
}
}
$gradTieIn
=
$course
->
getGradTieIn
();
if
(
$gradTieIn
[
'credits'
])
{
$courseNode
->
appendChild
(
$dom
->
createElement
(
'gradCredits'
,
htmlspecialchars
(
$gradTieIn
[
'credits'
],
null
,
'UTF-8'
)));
}
if
(
$node
=
$this
->
_getNodeFromHtmlFragment
(
$dom
,
'gradNotes'
,
$gradTieIn
[
'notes'
]))
{
$courseNode
->
appendChild
(
$node
);
}
if
(
$node
=
$this
->
_getNodeFromHtmlFragment
(
$dom
,
'gradPrerequisites'
,
$gradTieIn
[
'prerequisites'
]))
{
$courseNode
->
appendChild
(
$node
);
}
$root
->
appendChild
(
$courseNode
);
}
header
(
'Content-type: text/xml'
);
$dom
->
normalize
();
echo
$dom
->
saveXML
();
}
protected
function
_getNodeFromHtmlFragment
(
$dom
,
$nodeName
,
$fragment
)
{
$fragment
=
trim
(
$fragment
);
if
(
!
$fragment
)
{
return
null
;
}
$node
=
new
DOMDocument
(
'1.0'
,
'UTF-8'
);
$fragment
=
'<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head><body>'
.
$fragment
.
'</body>'
;
$node
=
DOMDocument
::
loadHTML
(
strtr
(
$fragment
,
array
(
'&'
=>
'&'
)));
if
(
!
$node
->
documentElement
)
{
return
null
;
}
$node
=
$dom
->
importNode
(
$node
->
documentElement
,
true
);
$realNode
=
$node
->
childNodes
->
item
(
1
);
$newNode
=
$dom
->
createElement
(
$nodeName
);
while
(
$realNode
->
hasChildNodes
())
{
$newNode
->
appendChild
(
$realNode
->
childNodes
->
item
(
0
));
}
return
$newNode
;
}
}
/**
/**
...
@@ -25,10 +159,8 @@ class Courses_PublicViewController extends App_Controller_Action {
...
@@ -25,10 +159,8 @@ class Courses_PublicViewController extends App_Controller_Action {
*/
*/
public
function
testAction
()
public
function
testAction
()
{
{
$layout
=
Zend_Layout
::
getMvcInstance
();
$this
->
_disableLayoutAndView
();
$layout
->
disableLayout
();
//header('Content-type: text/plain');
$this
->
getFrontController
()
->
setParam
(
'noViewRenderer'
,
true
);
header
(
'Content-type: text/plain'
);
$db
=
Zend_Registry
::
get
(
'db'
);
$db
=
Zend_Registry
::
get
(
'db'
);
...
...
This diff is collapsed.
Click to expand it.
application/modules/courses/models/CourseModel.php
+
21
−
5
View file @
7ddaeb3d
...
@@ -127,6 +127,7 @@ class Courses_CourseModel extends Unl_Model
...
@@ -127,6 +127,7 @@ class Courses_CourseModel extends Unl_Model
// Credits
// Credits
$select
=
new
Zend_Db_Select
(
$db
);
$select
=
new
Zend_Db_Select
(
$db
);
$select
->
from
(
array
(
'c'
=>
'creqCourseCredits'
));
$select
->
from
(
array
(
'c'
=>
'creqCourseCredits'
));
$select
->
join
(
array
(
't'
=>
'creqCreditTypes'
),
'c.type = t.creditTypeId'
,
array
(
'description'
));
$select
->
where
(
'c.generation IN(?)'
,
$courseIds
);
$select
->
where
(
'c.generation IN(?)'
,
$courseIds
);
$records
=
$select
->
query
()
->
fetchAll
();
$records
=
$select
->
query
()
->
fetchAll
();
...
@@ -358,7 +359,7 @@ class Courses_CourseModel extends Unl_Model
...
@@ -358,7 +359,7 @@ class Courses_CourseModel extends Unl_Model
}
}
}
}
static
public
function
findByCourseCode
(
$subject
,
$courseNumber
,
$courseLetter
=
null
)
static
public
function
findByCourseCode
(
$subject
,
$courseNumber
,
$courseLetter
=
''
)
{
{
$db
=
Zend_Registry
::
get
(
'db'
);
$db
=
Zend_Registry
::
get
(
'db'
);
...
@@ -370,9 +371,7 @@ class Courses_CourseModel extends Unl_Model
...
@@ -370,9 +371,7 @@ class Courses_CourseModel extends Unl_Model
$select
->
where
(
'g.removed = "no"'
);
$select
->
where
(
'g.removed = "no"'
);
$select
->
where
(
'c.subject = ?'
,
$subject
);
$select
->
where
(
'c.subject = ?'
,
$subject
);
$select
->
where
(
'c.courseNumber = ?'
,
$courseNumber
);
$select
->
where
(
'c.courseNumber = ?'
,
$courseNumber
);
if
(
$courseLetter
)
{
$select
->
where
(
'c.courseLetter = ?'
,
$courseLetter
);
$select
->
where
(
'c.courseLetter = ?'
,
$courseLetter
);
}
$records
=
$select
->
query
()
->
fetchAll
();
$records
=
$select
->
query
()
->
fetchAll
();
if
(
count
(
$records
)
==
0
)
{
if
(
count
(
$records
)
==
0
)
{
...
@@ -408,6 +407,23 @@ class Courses_CourseModel extends Unl_Model
...
@@ -408,6 +407,23 @@ class Courses_CourseModel extends Unl_Model
return
$requests
;
return
$requests
;
}
}
static
public
function
findAllActive
()
{
$db
=
Zend_Registry
::
get
(
'db'
);
$select
=
new
Zend_Db_Select
(
$db
);
$select
->
from
(
array
(
'g'
=>
'creqCourseGenerations'
),
array
(
'courseGenerationId'
));
$select
->
join
(
array
(
'p'
=>
'creqCourses'
),
'g.courseGenerationId = p.currentGeneration'
,
array
());
$select
->
where
(
'g.removed = "no"'
);
$records
=
$select
->
query
()
->
fetchAll
();
$generationIds
=
array
();
foreach
(
$records
as
$row
)
{
$generationIds
[]
=
$row
[
'courseGenerationId'
];
}
return
self
::
find
(
$generationIds
);
}
static
public
function
save
(
$models
)
static
public
function
save
(
$models
)
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment