CcConverterForum   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 22
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A convert() 0 21 2
1
<?php
2
/* Source: https://github.com/moodle/moodle/blob/MOODLE_310_STABLE/backup/cc/cc_lib/cc_converter_forum.php under GNU/GPL license */
3
4
class CcConverterForum extends CcConverters
5
{
6
    public function __construct(CcIItem &$item, CcIManifest &$manifest, $rootpath, $path)
7
    {
8
        $this->ccType = CcVersion13::DISCUSSIONTOPIC;
9
        $this->defaultfile = 'forum.xml';
10
        $this->defaultname = 'discussion.xml';
11
        parent::__construct($item, $manifest, $rootpath, $path);
12
    }
13
14
    public function convert($outdir, $item)
15
    {
16
        $rt = new CcForum();
17
        $title = $item['title'];
18
        $rt->setTitle($title);
19
        $text = $item['comment'];
20
        $deps = null;
21
        if (!empty($text)) {
22
            $contextid = $item['source_id'];
23
            $result = CcHelpers::processLinkedFiles($text,
24
                                                       $this->manifest,
25
                                                       $this->rootpath,
26
                                                       $contextid,
27
                                                       $outdir);
28
            $textformat = 'text/html';
29
            $rt->setText($result[0], $textformat);
30
            $deps = $result[1];
31
        }
32
        $this->store($rt, $outdir, $title, $deps);
33
34
        return true;
35
    }
36
}
37