PageRenderTime 18ms CodeModel.GetById 11ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/php/component/uploader.class.php

https://bitbucket.org/chamilo/chamilo-ext-repo-box-dev/
PHP | 55 lines | 48 code | 7 blank | 0 comment | 3 complexity | 2183c74386b87d5b15c28a1b52cc315c MD5 | raw file
 1<?php
 2namespace common\extensions\external_repository_manager\implementation\box;
 3
 4use common\libraries\Path;
 5use common\libraries\Redirect;
 6use common\libraries\Request;
 7use common\libraries\application;
 8use common\libraries\Translation;
 9
10use common\extensions\external_repository_manager\ExternalRepositoryManager;
11
12require_once dirname(__FILE__) . '/../forms/box_external_repository_manager_form.class.php';
13
14class BoxExternalRepositoryManagerUploaderComponent extends BoxExternalRepositoryManager
15{
16
17    function run()
18    {
19        $form = new BoxExternalRepositoryManagerForm(BoxExternalRepositoryManagerForm :: TYPE_CREATE, $this->get_url(), $this);
20        
21        if ($form->validate())
22        {
23            $id = $form->upload_file();
24            if ($id)
25            {
26                $parameters = $this->get_parameters();
27                $parameters[ExternalRepositoryManager :: PARAM_EXTERNAL_REPOSITORY_MANAGER_ACTION] = ExternalRepositoryManager :: ACTION_VIEW_EXTERNAL_REPOSITORY;
28                $parameters[ExternalRepositoryManager :: PARAM_EXTERNAL_REPOSITORY_ID] = $id;
29                
30                if ($this->is_stand_alone())
31                {
32                    Redirect :: web_link(Path :: get(WEB_PATH) . 'common/launcher/index.php', $parameters);
33                }
34                else
35                {
36                    Redirect :: web_link(Path :: get(WEB_PATH) . 'index.php', $parameters);
37                }
38            }
39            else
40            {
41                Request :: set_get(Application :: PARAM_ERROR_MESSAGE, Translation :: get('BoxUploadProblem'));
42                $this->display_header();
43                $form->display();
44                $this->display_footer();
45            }
46        }
47        else
48        {
49            $this->display_header();
50            $form->display();
51            $this->display_footer();
52        }
53    }
54}
55?>