lib.php 3.9 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
/**
 * Mahara: Electronic portfolio, weblog, resume builder and social networking
 * Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package    mahara
 * @subpackage artefact-internal-export-html
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
 *
 */

defined('INTERNAL') || die();

class HtmlExportInternal extends HtmlExportArtefactPlugin {

    public function dump_export_data() {
32
        $smarty = $this->exporter->get_smarty('../../');
Nigel McNie's avatar
Nigel McNie committed
33
34
35

        // Profile page
        $smarty->assign('breadcrumbs', array(array('text' => 'Profile page', 'path' => 'profilepage.html')));
36
        $view = $this->exporter->get('user')->get_profile_view();
37
38
        $outputfilter = new HtmlExportOutputFilter('../../');
        $smarty->assign('view', $outputfilter->filter($view->build_columns()));
39
40
41
42
43
44
45

        $content = $smarty->fetch('export:html/internal:profilepage.tpl');
        if (!file_put_contents($this->fileroot . 'profilepage.html', $content)) {
            throw new SystemException("Unable to write profile page");
        }

        // Generic profile information
Nigel McNie's avatar
Nigel McNie committed
46
47
        $smarty->assign('breadcrumbs', array(array('text' => 'Profile information', 'path' => 'index.html')));

48
49
50
51
52
53
54
55
56
57
58
59
60
        $sections = array();
        $elementlist = call_static_method('ArtefactTypeProfile', 'get_all_fields');
        $profilefields = get_column_sql('SELECT id FROM {artefact} WHERE owner=? AND artefacttype IN ('
            . join(",",array_map(create_function('$a','return db_quote($a);'),array_keys($elementlist)))
            . ")", array($this->exporter->get('user')->get('id')));
        foreach ($profilefields as $id) {
            $artefact = artefact_instance_from_id($id);
            $rendered = $artefact->render_self(array());
            $sections[$this->get_category_for_artefacttype($artefact->get('artefacttype'))][$artefact->get('artefacttype')] = $rendered['html'];
        }

        $smarty->assign('sections', $sections);

61
62
        $content = $smarty->fetch('export:html/internal:index.tpl');
        if (!file_put_contents($this->fileroot . 'index.html', $content)) {
63
64
            throw new SystemException("Unable to write profile information page");
        }
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
    }

    public function get_summary() {
        $smarty = $this->exporter->get_smarty();
        $smarty->assign('introduction', get_profile_field($this->exporter->get('user')->get('id'), 'introduction'));
        $iconid = $this->exporter->get('user')->get('profileicon');
        if ($iconid) {
            $icon = artefact_instance_from_id($iconid);
            // TODO: protect title from /'s
            $smarty->assign('icon', '<img src="static/profileicons/200px-' . $icon->get('title') . '" alt="Profile Icon">');
        }
        return array(
            'description' => $smarty->fetch('export:html/internal:summary.tpl'),
        );
    }

    public function get_summary_weight() {
        return 0;
    }

85
86
87
88
89
90
91
92
93
94
95
96
    private function get_category_for_artefacttype($artefacttype) {
        switch ($artefacttype) {
        case 'firstname':
        case 'lastname':
            return 'basic';
        case 'email':
            return 'contact';
        default:
            return 'unclassified';
        }
    }

97
98
99
}

?>