Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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
/**
18
 * Utility lang import functions.
19
 *
20
 * @package    tool
21
 * @subpackage langimport
22
 * @copyright  2011 Petr Skoda
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
defined('MOODLE_INTERNAL') || die;
27
 
28
/**
29
 * Called during upgrade, we need up-to-date lang pack
30
 * because it may be used during upgrade...
31
 *
32
 * @param string $lang
33
 * @return void
34
 */
35
function tool_langimport_preupgrade_update($lang) {
36
    global $CFG, $OUTPUT;
37
    require_once($CFG->libdir.'/componentlib.class.php');
38
 
39
    echo $OUTPUT->heading(get_string('langimport', 'tool_langimport').': '.$lang);
40
 
41
    @mkdir ($CFG->tempdir.'/');    //make it in case it's a fresh install, it might not be there
42
    @mkdir ($CFG->dataroot.'/lang/');
43
 
44
    $installer = new lang_installer($lang);
45
    $results = $installer->run();
46
    foreach ($results as $langcode => $langstatus) {
47
        switch ($langstatus) {
48
        case lang_installer::RESULT_DOWNLOADERROR:
49
            echo $OUTPUT->notification($langcode . '.zip');
50
            break;
51
        case lang_installer::RESULT_INSTALLED:
52
            echo $OUTPUT->notification(get_string('langpackinstalled', 'tool_langimport', $langcode), 'notifysuccess');
53
            break;
54
        case lang_installer::RESULT_UPTODATE:
55
            echo $OUTPUT->notification(get_string('langpackuptodate', 'tool_langimport', $langcode), 'notifysuccess');
56
            break;
57
        }
58
    }
59
}