Issues (1796)

public/plugin/TopLinks/index.php (1 issue)

Labels
Severity
1
<?php
2
3
/* For license terms, see /license.txt */
4
5
use Chamilo\PluginBundle\TopLinks\Entity\TopLinkRelTool;
6
7
$httpRequest = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
8
9
if ('/main/course_home/course_home.php' === $httpRequest->getScriptName()) {
10
    $course = api_get_course_entity();
11
12
    $em = Database::getManager();
13
    $linkToolRepo = $em->getRepository(TopLinkRelTool::class);
14
15
    $linkTools = $linkToolRepo->findInCourse($course);
16
17
    $toolIds = [];
18
19
    /** @var TopLinkRelTool $linkTool */
20
    foreach ($linkTools as $linkTool) {
21
        $toolIds[] = [
22
            'id' => $linkTool->getTool()->getIid(),
23
            'img' => $linkTool->getLink()->getIcon()
24
                ? api_get_path(WEB_UPLOAD_PATH).'plugins/TopLinks/'.$linkTool->getLink()->getIcon()
0 ignored issues
show
The constant WEB_UPLOAD_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
25
                : null,
26
        ];
27
    } ?>
28
    <script>
29
        $(function () {
30
            var ids = JSON.parse('<?php echo json_encode($toolIds); ?>');
31
32
            $(ids).each(function (index, iconTool) {
33
                var $toolA = $('#tooldesc_' + iconTool.id);
34
                var $toolImg = $toolA.find('img#toolimage_' + iconTool.id);
35
36
                if (iconTool.img) {
37
                    $toolImg.prop('src', iconTool.img).data('forced-src', iconTool.img);
38
                }
39
40
                var $block = $toolA.parents('.course-tool').parent();
41
42
                $block.prependTo($block.parent());
43
            });
44
        });
45
    </script>
46
    <?php
47
}
48