1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
declare(strict_types = 1);
|
|
|
18 |
|
|
|
19 |
namespace mod_edusharing;
|
|
|
20 |
|
|
|
21 |
use Exception;
|
|
|
22 |
|
|
|
23 |
/**
|
|
|
24 |
* Class MetaDataFrontend
|
|
|
25 |
*
|
|
|
26 |
* @author Marian Ziegler <ziegler@edu-sharnig.net>
|
|
|
27 |
* @package mod_edusharing
|
|
|
28 |
*/
|
|
|
29 |
class MetaDataFrontend {
|
|
|
30 |
/**
|
|
|
31 |
* Function get_repo_form
|
|
|
32 |
*
|
|
|
33 |
* @return string|null
|
|
|
34 |
*/
|
|
|
35 |
public static function get_repo_form(): ?string {
|
|
|
36 |
try {
|
|
|
37 |
$repourl = get_config('edusharing', 'application_cc_gui_url') !== false
|
|
|
38 |
? get_config('edusharing', 'application_cc_gui_url') : '';
|
|
|
39 |
$appid = get_config('edusharing', 'application_appid') !== false
|
|
|
40 |
? get_config('edusharing', 'application_appid') : '';
|
|
|
41 |
$hostaliases = get_config('edusharing', 'application_host_aliases') !== false
|
|
|
42 |
? get_config('edusharing', 'application_host_aliases') : '';
|
|
|
43 |
} catch (Exception $exception) {
|
|
|
44 |
unset($exception);
|
|
|
45 |
return '<p style="background: #FF8170">Error<br></p>';
|
|
|
46 |
}
|
|
|
47 |
if (!empty($repourl)) {
|
|
|
48 |
// phpcs:disable -- This is just messy html and inline js
|
|
|
49 |
return '
|
|
|
50 |
<form class="repo-reg" action="import_metadata.php" method="post">
|
|
|
51 |
<h3>Try to register the edu-sharing moodle-plugin with a repository:</h3>
|
|
|
52 |
<p>If your moodle is behind a proxy-server, this might not work and you have to register the plugin manually.</p>
|
|
|
53 |
<div class="edu_metadata">
|
|
|
54 |
<div class="repo_input">
|
|
|
55 |
<p class="repo_input_name">Repo-URL:</p><input type="text" value="'. $repourl .'" name="repoUrl" />
|
|
|
56 |
</div>
|
|
|
57 |
<div class="repo_input">
|
|
|
58 |
<p class="repo_input_name">Repo-Admin-User:</p><input class="short_input" type="text" name="repoAdmin">
|
|
|
59 |
<p class="repo_input_name">Repo-Admin-Password:</p><input class="short_input" type="password" name="repoPwd">
|
|
|
60 |
</div>
|
|
|
61 |
<div class="repo_input">
|
|
|
62 |
<p class="repo_input_name">Change Moodle-AppID:</p><input type="text" value="'. $appid .'" name="appId" />
|
|
|
63 |
<p>(optional)</p>
|
|
|
64 |
</div>
|
|
|
65 |
<div class="repo_input">
|
|
|
66 |
<p class="repo_input_name">Add Host-Alias:</p><input type="text" value="'. $hostaliases .'" name="host_aliases" />
|
|
|
67 |
<p>(optional)</p>
|
|
|
68 |
</div>
|
|
|
69 |
<input class="btn" type="submit" value="Register Repo" name="repoReg">
|
|
|
70 |
</div>
|
|
|
71 |
</form>
|
|
|
72 |
';
|
|
|
73 |
// phpcs:enable
|
|
|
74 |
}
|
|
|
75 |
return null;
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
/**
|
|
|
79 |
* Function get_meta_data_form
|
|
|
80 |
*
|
|
|
81 |
* Returns the form to input the metadata url
|
|
|
82 |
*
|
|
|
83 |
* @return string
|
|
|
84 |
*/
|
|
|
85 |
public static function get_meta_data_form(): string {
|
|
|
86 |
global $CFG;
|
|
|
87 |
// phpcs:disable -- This is just messy html and inline js
|
|
|
88 |
return '
|
|
|
89 |
<form action="import_metadata.php" method="post" name="mdform">
|
|
|
90 |
<h3>Enter your metadata endpoint here:</h3>
|
|
|
91 |
<p>Hint: Just click on the example to copy it into the input-field.</p>
|
|
|
92 |
<div class="edu_metadata">
|
|
|
93 |
<div class="edu_endpoint">
|
|
|
94 |
<p>Metadata-Endpoint:</p>
|
|
|
95 |
<input type="text" id="metadata" name="mdataurl" value="">
|
|
|
96 |
<input class="btn" type="submit" value="Import">
|
|
|
97 |
</div>
|
|
|
98 |
<div class="edu_example">
|
|
|
99 |
<p>(Example: <a href="javascript:void();"
|
|
|
100 |
onclick="document.forms[0].mdataurl.value=\'http://your-server-name/edu-sharing/metadata?format=lms&external=true\'">
|
|
|
101 |
http://your-server-name/edu-sharing/metadata?format=lms&external=true</a>)
|
|
|
102 |
</p>
|
|
|
103 |
</div>
|
|
|
104 |
</div>
|
|
|
105 |
</form>
|
|
|
106 |
<p>To export the edu-sharing plugin metadata use the following url: <span class="edu_export">' . $CFG->wwwroot . '/mod/edusharing/metadata.php</span></p>';
|
|
|
107 |
// phpcs:enable
|
|
|
108 |
}
|
|
|
109 |
}
|