Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UNL_GraduateBulletin
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
Digital Experience Group
UNL_GraduateBulletin
Commits
5ac2b1a7
Commit
5ac2b1a7
authored
10 years ago
by
Kevin Abel
Browse files
Options
Downloads
Patches
Plain Diff
Update course Utilities from Undergrad bulletin
parent
9cc64406
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/UNL/Catalog/Course/Utilities.php
+11
-12
11 additions, 12 deletions
src/UNL/Catalog/Course/Utilities.php
with
11 additions
and
12 deletions
src/UNL/Catalog/Course/Utilities.php
+
11
−
12
View file @
5ac2b1a7
...
...
@@ -2,6 +2,8 @@
namespace
UNL\Catalog\Course
;
use
UNL\Catalog\Controller
;
/**
* The EPUB files exported from InDesign contain simple markup with a few class names.
*
...
...
@@ -24,7 +26,8 @@ class Utilities
$html
=
self
::
convertHeadings
(
$html
);
$html
=
self
::
addLeaders
(
$html
);
$html
=
self
::
linkURLs
(
$html
);
$html
=
self
::
addCourseLinks
(
$html
);
$html
=
self
::
addCourseLinks
(
$html
,
Controller
::
getURL
());
return
$html
;
}
...
...
@@ -47,10 +50,10 @@ class Utilities
$replacements
=
array
(
// trim off pointless "generated-style" spans
'/<span class="generated-style">([^<]*)<\/span>/'
=>
'$1'
,
'/<p class="content-box-h-1"[^>]*>([^<]*)<\/p>/'
=>
'<h2 class="
sec_header
content-box-h-1">$1</h2>'
,
'/<p class="content-box-m-p"[^>]*>([^<]*)<\/p>/'
=>
'<h2 class="
sec_header
content-box-m-p">$1</h2>'
,
'/<p class="content-box-h-1"[^>]*>([^<]*)<\/p>/'
=>
'<h2 class="content-box-h-1">$1</h2>'
,
'/<p class="content-box-m-p"[^>]*>([^<]*)<\/p>/'
=>
'<h2 class="content-box-m-p">$1</h2>'
,
'/<p class="section-1"[^>]*>([^<]*)<\/p>/'
=>
'<h3 class="section-1">$1</h3>'
,
'/<p class="title-1"[^>]*>([^<]*)<\/p>/'
=>
'<h3 class="title-1"
>
$1</h3>'
,
'/<p class="title-1"
(
[^>]*
)
>([^<]*)<\/p>/'
=>
'<h3 class="title-1"$1
>$2
</h3>'
,
'/<p class="title-2"[^>]*>([^<]*)<\/p>/'
=>
'<h4 class="title-2">$1</h4>'
,
'/<p class="title-3"[^>]*>([^<]*)<\/p>/'
=>
'<h5 class="title-3">$1</h5>'
,
'/<p class="section-2"[^>]*>([^<]*)<\/p>/'
=>
'<h4 class="section-2">$1</h4>'
,
...
...
@@ -76,12 +79,8 @@ class Utilities
public
static
function
addLeaders
(
$html
)
{
$html
=
preg_replace
(
'/<br \/>/'
,
' '
,
$html
);
$html
=
preg_replace
(
'/<p class="(requirement-sec-[1-3])"[^>]*>(.*)\s([\d]{1,2})[\s]*<\/p>/'
,
'<p class="$1"><span class="req_desc">$2</span><span class="leader"></span><span class="req_value">$3</span></p>'
,
$html
);
$html
=
preg_replace
(
'/<p class="(requirement-sec-[1-4]\-ledr)"[^>]*>(.*)\s([\d]{1,2})[\s]*<\/p>/'
,
'<p class="$1"><span class="req_desc">$2</span><span class="leader"></span><span class="req_value">$3</span></p>'
,
$html
);
$html
=
preg_replace
(
'/<p class="(requirement-sec-[1-3]\-note)"[^>]*>(.*)\s([\d]{1,2})[\s]*<\/p>/'
,
'<p class="$1"><span class="req_desc">$2</span><span class="leader"></span><span class="req_value">$3</span></p>'
,
$html
);
$html
=
preg_replace
(
'/<p class="(requirement-sec-[1-3])"[^>]*>(.*)\s([\d]{1,2}\-[\d]{1,2})[\s]*<\/p>/'
,
'<p class="$1"><span class="req_desc">$2</span><span class="leader"></span><span class="req_value">$3</span></p>'
,
$html
);
$html
=
preg_replace
(
'/<p class="(requirement-sec-[1-4]\-ledr)"[^>]*>(.*)\s([\d]{1,2}\-[\d]{1,2})[\s]*<\/p>/'
,
'<p class="$1"><span class="req_desc">$2</span><span class="leader"></span><span class="req_value">$3</span></p>'
,
$html
);
$html
=
preg_replace
(
'/<p class="(requirement-sec-1)"[^>]*>(.*)\s([\d]{2,3})[\s]*<\/p>/'
,
'<p class="$1"><span class="req_desc">$2</span><span class="leader"></span><span class="req_value">$3</span></p>'
,
$html
);
$html
=
preg_replace
(
'/<p class="(requirement-sec-[1-4](?:\-(?:ledr|note))?)"[^>]*>(.*)\s([\d]{1,2}(?:\-[\d]{1,3})?)[\s]*<\/p>/'
,
'<p class="$1"><span class="req_desc">$2</span><span class="leader"></span><span class="req_value">$3</span></p>'
,
$html
);
$html
=
preg_replace
(
'/<p class="(abbreviations-list)"[^>]*>(((\sor\s)?[^\s]+)+)\s([^<]*)(<span.*>.*<\/span>)?<\/p>/'
,
'<p class="$1"><span class="req_desc">$2</span><span class="leader"></span><span class="req_value">$5 $6</span></p>'
,
$html
);
return
$html
;
}
...
...
@@ -110,7 +109,7 @@ class Utilities
.
")"
.
"([0-9]
{
2,3
}
[A-Z]?) # course number, with optional letter
\n
"
.
")+"
.
"
([\.\s\<\,\;\/\)]|$) # characters which signal the end of a course sequence
\n
"
.
"
\b(?!<\w) # the end of a word and not the start of HTML
\n
"
.
"/x"
,
$callback
,
$text
);
...
...
@@ -128,7 +127,7 @@ class Utilities
{
$courses
=
array
();
$callback
=
function
(
$matches
)
use
(
&
$courses
)
{
if
(
!
UNL_UndergraduateBulletin_EPUB_Utilities
::
isValidSubjectCode
(
$matches
[
1
]))
{
if
(
!
self
::
isValidSubjectCode
(
$matches
[
1
]))
{
return
;
}
...
...
@@ -187,7 +186,7 @@ class Utilities
public
static
function
addCourseLinks
(
$text
,
$url
=
''
)
{
return
self
::
courseScanCallback
(
$text
,
function
(
$matches
)
use
(
$url
)
{
return
Utilities
::
linkCourse
(
$matches
,
$url
);
return
self
::
linkCourse
(
$matches
,
$url
);
});
}
...
...
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