Skip to content

Commit

Permalink
OAI-PMH: Use template_name from database if the name attribute in LO …
Browse files Browse the repository at this point in the history
…is empty

If name attribute of the project is empty, the template_name of the templatedetails table is used as the title.
  • Loading branch information
torinfo committed Jul 3, 2023
1 parent 063b64c commit 6be3ac5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion oai-pmh/management/reset.php
Expand Up @@ -82,7 +82,7 @@ function getMetaData($templates, $publish_status)
$template_creator = $template['owner_username'];
$template_type = $template['template_type'];

$meta = get_meta_data($template_id, $template_creator, $template_type);
$meta = get_meta_data($template_id, $template['template_name'], $template_creator, $template_type);

$meta->oai_published = $meta->oaiPmhAgree && $meta->domain != 'unknown' && $meta->level != 'unknown';

Expand Down
4 changes: 2 additions & 2 deletions oai-pmh/oai.php
Expand Up @@ -193,7 +193,7 @@ function getSingleTemplate($metadataPrefix,$template_id) {
if (!$response_template) {
throw new OAIException('idDoesNotExist');
}
$tempMetaData = call_user_func(get_meta_data,$response_template[0]['template_id'],$response_template[0]["owner_username"],$response_template[0]["template_type"],$response_template[0]['owner']);
$tempMetaData = call_user_func(get_meta_data,$response_template[0]['template_id'],$response_template[0]['template_name'],$response_template[0]["owner_username"],$response_template[0]["template_type"],$response_template[0]['owner']);
$response_record = call_user_func(makeRecordFromTemplate,$metadataPrefix,$response_template[0], $tempMetaData);

return $response_record;
Expand Down Expand Up @@ -266,7 +266,7 @@ function getTemplates($metadataPrefix,$from,$until) {
$needle_key = array_search($currentTemplate['template_id'], array_column($publish_status, 'template_id'));
if ($needle_key !== false){
if (strcmp($publish_status[$needle_key]['status'], "published") == 0) {
$tempMetaData = call_user_func('get_meta_data',$currentTemplate['template_id'],$currentTemplate["owner_username"],$currentTemplate["template_type"], $currentTemplate['owner']);
$tempMetaData = call_user_func('get_meta_data',$currentTemplate['template_id'],$currentTemplate['template_name'],$currentTemplate["owner_username"],$currentTemplate["template_type"], $currentTemplate['owner']);
if($tempMetaData->domain != 'unknown' and $tempMetaData->level != "unknown" and $tempMetaData->oaiPmhAgree){
$currentRecord = call_user_func('makeRecordFromTemplate',$metadataPrefix,$currentTemplate, $tempMetaData);
$tmpRecords[] = $currentRecord;
Expand Down
6 changes: 5 additions & 1 deletion oai-pmh/xerteobjects.php
Expand Up @@ -20,7 +20,7 @@

require_once(dirname(__FILE__) . "/Html2Text.php");
require_once(dirname(__FILE__) . "/../website_code/php/url_library.php");
function get_meta_data($template_id, $creator_user_name="", $template_type_name="", $template_owner="")
function get_meta_data($template_id, $template_name, $creator_user_name="", $template_type_name="", $template_owner="")
{
global $config;
global $xerte_toolkits_site;
Expand All @@ -30,6 +30,10 @@ function get_meta_data($template_id, $creator_user_name="", $template_type_name=

$html = new \Html2Text\Html2Text((string)$xml['name']);
$xerteMetaObj->name = $html->getText();
if (trim($xerteMetaObj->name) == "")
{
$xerteMetaObj->name = str_replace("_", " ", $template_name);
}

if (isset($xml['educode']))
{
Expand Down

0 comments on commit 6be3ac5

Please sign in to comment.