Issues (2113)

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

Labels
Severity
1
<?php
2
3
/* For license terms, see /license.txt */
4
5
use Chamilo\CoreBundle\Framework\Container;
6
use Chamilo\PluginBundle\TopLinks\Entity\TopLinkRelTool;
7
8
$httpRequest = Container::getRequest();
9
10
if ('/main/course_home/course_home.php' === $httpRequest->getScriptName()) {
11
    $course = api_get_course_entity();
12
13
    $em = Database::getManager();
14
    $linkToolRepo = $em->getRepository(TopLinkRelTool::class);
15
16
    $linkTools = $linkToolRepo->findInCourse($course);
17
18
    $toolIds = [];
19
20
    /** @var TopLinkRelTool $linkTool */
21
    foreach ($linkTools as $linkTool) {
22
        $toolIds[] = [
23
            'id' => $linkTool->getTool()->getIid(),
24
            'img' => $linkTool->getLink()->getIcon()
25
                ? 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...
26
                : null,
27
        ];
28
    } ?>
29
    <script>
30
        $(function () {
31
            var ids = JSON.parse('<?php echo json_encode($toolIds); ?>');
32
33
            $(ids).each(function (index, iconTool) {
34
                var $toolA = $('#tooldesc_' + iconTool.id);
35
                var $toolImg = $toolA.find('img#toolimage_' + iconTool.id);
36
37
                if (iconTool.img) {
38
                    $toolImg.prop('src', iconTool.img).data('forced-src', iconTool.img);
39
                }
40
41
                var $block = $toolA.parents('.course-tool').parent();
42
43
                $block.prependTo($block.parent());
44
            });
45
        });
46
    </script>
47
    <?php
48
}
49