Skip to content

Commit

Permalink
Merge pull request #2190 from bywatersolutions/DIS-178
Browse files Browse the repository at this point in the history
DIS-178 - Use mb_substr to preserve diacritics
  • Loading branch information
mdnoble73 authored Jan 9, 2025
2 parents de22de8 + 449a0fc commit e5bc70d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
2 changes: 2 additions & 0 deletions code/web/release_notes/25.02.00.MD
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

//kidclamp

Use mb_substr to presrve diacritics in lists (DIS-178) (*WNC*)

//yanjun

//lukeg
Expand Down
54 changes: 27 additions & 27 deletions code/web/services/MyAccount/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -1567,79 +1567,79 @@ function addList() {
$groupedWork = new GroupedWork();
$groupedWork->permanent_id = $userListEntry->sourceId;
if ($groupedWork->find(true)) {
$userListEntry->title = substr($groupedWork->full_title, 0, 50);
$userListEntry->title = mb_substr($groupedWork->full_title, 0, 50);
}
} elseif ($userListEntry->source == 'Lists') {
require_once ROOT_DIR . '/sys/UserLists/UserList.php';
$list = new UserList();
$list->id = $userListEntry->sourceId;
if ($list->find(true)) {
$userListEntry->title = substr($list->title, 0, 50);
$userListEntry->title = mb_substr($list->title, 0, 50);
}
} elseif ($userListEntry->source == 'Events') {
if (preg_match('`^communico`', $userListEntry->sourceId)) {
require_once ROOT_DIR . '/RecordDrivers/CommunicoEventRecordDriver.php';
$recordDriver = new CommunicoEventRecordDriver($userListEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userListEntry->title = substr($title, 0, 50);
$userListEntry->title = mb_substr($title, 0, 50);
}
} elseif (preg_match('`^libcal`', $userListEntry->sourceId)) {
require_once ROOT_DIR . '/RecordDrivers/SpringshareLibCalEventRecordDriver.php';
$recordDriver = new SpringshareLibCalEventRecordDriver($userListEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userListEntry->title = substr($title, 0, 50);
$userListEntry->title = mb_substr($title, 0, 50);
}
} elseif (preg_match('`^assabet`', $userListEntry->sourceId)) {
require_once ROOT_DIR . '/RecordDrivers/AssabetEventRecordDriver.php';
$recordDriver = new AssabetEventRecordDriver($userListEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userListEntry->title = substr($title, 0, 50);
$userListEntry->title = mb_substr($title, 0, 50);
}
} else {
require_once ROOT_DIR . '/RecordDrivers/LibraryCalendarEventRecordDriver.php';
$recordDriver = new LibraryCalendarEventRecordDriver($userListEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userListEntry->title = substr($title, 0, 50);
$userListEntry->title = mb_substr($title, 0, 50);
}
}
} elseif ($userListEntry->source == 'OpenArchives') {
require_once ROOT_DIR . '/RecordDrivers/OpenArchivesRecordDriver.php';
$recordDriver = new OpenArchivesRecordDriver($userListEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userListEntry->title = substr($title, 0, 50);
$userListEntry->title = mb_substr($title, 0, 50);
}
} elseif ($userListEntry->source == 'Genealogy') {
require_once ROOT_DIR . '/sys/Genealogy/Person.php';
$person = new Person();
$person->personId = $userListEntry->sourceId;
if ($person->find(true)) {
$userListEntry->title = substr($person->firstName . $person->middleName . $person->lastName, 0, 50);
$userListEntry->title = mb_substr($person->firstName . $person->middleName . $person->lastName, 0, 50);
}
} elseif ($userListEntry->source == 'EbscoEds') {
require_once ROOT_DIR . '/RecordDrivers/EbscoRecordDriver.php';
$recordDriver = new EbscoRecordDriver($userListEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userListEntry->title = substr($title, 0, 50);
$userListEntry->title = mb_substr($title, 0, 50);
}
} elseif ($userListEntry->source == 'Ebscohost') {
require_once ROOT_DIR . '/RecordDrivers/EbscohostRecordDriver.php';
$recordDriver = new EbscohostRecordDriver($userListEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userListEntry->title = substr($title, 0, 50);
$userListEntry->title = mb_substr($title, 0, 50);
}
} elseif ($userListEntry->source == 'Summon') {
require_once ROOT_DIR . '/RecordDrivers/SummonRecordDriver.php';
$recordDriver = new SummonRecordDriver($userListEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userListEntry->title = substr($title, 0, 50);
$userListEntry->title = mb_substr($title, 0, 50);
}
}
$userListEntry->insert();
Expand Down Expand Up @@ -7000,7 +7000,7 @@ function saveEvent() {
$recordDriver = new CommunicoEventRecordDriver($userEventsEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userEventsEntry->title = substr($title, 0, 50);
$userEventsEntry->title = mb_substr($title, 0, 50);
$eventDate = $recordDriver->getStartDate();
$userEventsEntry->eventDate = $eventDate->getTimestamp();
if ($recordDriver->isRegistrationRequired()) {
Expand All @@ -7017,7 +7017,7 @@ function saveEvent() {
$recordDriver = new SpringshareLibCalEventRecordDriver($userEventsEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userEventsEntry->title = substr($title, 0, 50);
$userEventsEntry->title = mb_substr($title, 0, 50);
$eventDate = $recordDriver->getStartDate();
$userEventsEntry->eventDate = $eventDate->getTimestamp();
if ($recordDriver->isRegistrationRequired()) {
Expand All @@ -7034,7 +7034,7 @@ function saveEvent() {
$recordDriver = new LibraryCalendarEventRecordDriver($userEventsEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userEventsEntry->title = substr($title, 0, 50);
$userEventsEntry->title = mb_substr($title, 0, 50);
$eventDate = $recordDriver->getStartDate();
$userEventsEntry->eventDate = $eventDate->getTimestamp();
if ($recordDriver->isRegistrationRequired()) {
Expand All @@ -7051,7 +7051,7 @@ function saveEvent() {
$recordDriver = new AssabetEventRecordDriver($userEventsEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userEventsEntry->title = substr($title, 0, 50);
$userEventsEntry->title = mb_substr($title, 0, 50);
$eventDate = $recordDriver->getStartDate();
$userEventsEntry->eventDate = $eventDate->getTimestamp();
if ($recordDriver->isRegistrationRequired()) {
Expand Down Expand Up @@ -7274,72 +7274,72 @@ function saveToList() {
$groupedWork = new GroupedWork();
$groupedWork->permanent_id = $userListEntry->sourceId;
if ($groupedWork->find(true)) {
$userListEntry->title = substr($groupedWork->full_title, 0, 50);
$userListEntry->title = mb_substr($groupedWork->full_title, 0, 50);
}
} elseif ($userListEntry->source == 'Lists') {
require_once ROOT_DIR . '/sys/UserLists/UserList.php';
$list = new UserList();
$list->id = $userListEntry->sourceId;
if ($list->find(true)) {
$userListEntry->title = substr($list->title, 0, 50);
$userListEntry->title = mb_substr($list->title, 0, 50);
}
} elseif ($userListEntry->source == 'Events') {
if (preg_match('`^communico`', $userListEntry->sourceId)) {
require_once ROOT_DIR . '/RecordDrivers/CommunicoEventRecordDriver.php';
$recordDriver = new CommunicoEventRecordDriver($userListEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userListEntry->title = substr($title, 0, 50);
$userListEntry->title = mb_substr($title, 0, 50);
}
} elseif (preg_match('`^libcal`', $userListEntry->sourceId)) {
require_once ROOT_DIR . '/RecordDrivers/SpringshareLibCalEventRecordDriver.php';
$recordDriver = new SpringshareLibCalEventRecordDriver($userListEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userListEntry->title = substr($title, 0, 50);
$userListEntry->title = mb_substr($title, 0, 50);
}
} elseif (preg_match('`^lc_`', $userListEntry->sourceId)) {
require_once ROOT_DIR . '/RecordDrivers/LibraryCalendarEventRecordDriver.php';
$recordDriver = new LibraryCalendarEventRecordDriver($userListEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userListEntry->title = substr($title, 0, 50);
$userListEntry->title = mb_substr($title, 0, 50);
}
} elseif (preg_match('`^assabet_`', $userListEntry->sourceId)) {
require_once ROOT_DIR . '/RecordDrivers/AssabetEventRecordDriver.php';
$recordDriver = new AssabetEventRecordDriver($userListEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userListEntry->title = substr($title, 0, 50);
$userListEntry->title = mb_substr($title, 0, 50);
}
}
} elseif ($userListEntry->source == 'OpenArchives') {
require_once ROOT_DIR . '/RecordDrivers/OpenArchivesRecordDriver.php';
$recordDriver = new OpenArchivesRecordDriver($userListEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userListEntry->title = substr($title, 0, 50);
$userListEntry->title = mb_substr($title, 0, 50);
}
} elseif ($userListEntry->source == 'Genealogy') {
require_once ROOT_DIR . '/sys/Genealogy/Person.php';
$person = new Person();
$person->personId = $userListEntry->sourceId;
if ($person->find(true)) {
$userListEntry->title = substr($person->firstName . $person->middleName . $person->lastName, 0, 50);
$userListEntry->title = mb_substr($person->firstName . $person->middleName . $person->lastName, 0, 50);
}
} elseif ($userListEntry->source == 'EbscoEds') {
require_once ROOT_DIR . '/RecordDrivers/EbscoRecordDriver.php';
$recordDriver = new EbscoRecordDriver($userListEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userListEntry->title = substr($title, 0, 50);
$userListEntry->title = mb_substr($title, 0, 50);
}
} elseif ($userListEntry->source == 'Summon') {
require_once ROOT_DIR . '/RecordDrivers/SummonRecordDriver.php';
$recordDriver = new SummonRecordDriver($userListEntry->sourceId);
if ($recordDriver->isValid()) {
$title = $recordDriver->getTitle();
$userListEntry->title = substr($title, 0, 50);
$userListEntry->title = mb_substr($title, 0, 50);
}
}
$existingEntry = false;
Expand Down Expand Up @@ -7421,8 +7421,8 @@ function saveToReadingHistory(): array {
$groupedWork->permanent_id = $sourceId;
if ($groupedWork->find(true)) {
$groupedWorkDriver = new GroupedWorkDriver($sourceId);
$readingHistoryEntry->title = substr($groupedWorkDriver->getTitle(), 0, 150);
$readingHistoryEntry->author = substr($groupedWorkDriver->getPrimaryAuthor(), 0, 75);
$readingHistoryEntry->title = mb_substr($groupedWorkDriver->getTitle(), 0, 150);
$readingHistoryEntry->author = mb_substr($groupedWorkDriver->getPrimaryAuthor(), 0, 75);
//Leave the format blank
$readingHistoryEntry->format = '';
$checkoutDate = mktime(0, 0, 0, $month, 1, $year);
Expand Down

0 comments on commit e5bc70d

Please sign in to comment.