-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdescription.php
124 lines (105 loc) · 5.7 KB
/
description.php
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/**
*
* Prints a desciption of the project (heading).
*
*
* @package mod-project
* @category mod
* @author Yann Ducruy (yann[dot]ducruy[at]gmail[dot]com). Contact me if needed
* @date 12/06/2015
* @version 3.2
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
*/
include_once 'forms/form_description.class.php';
$mform = new Description_Form($url, $project, $work);
if ($work == 'doexport'){
$heading = $DB->get_record('project_heading', array('projectid' => $project->id, 'groupid' => $currentGroupId));
$projects[$heading->projectid] = $heading;
include_once "xmllib.php";
$xml = recordstoxml($projects, 'project', '', true, null);
$escaped = str_replace('<', '<', $xml);
$escaped = str_replace('>', '>', $escaped);
echo $OUTPUT->heading(get_string('xmlexport', 'project'));
echo $OUTPUT->box("<pre>$escaped</pre>");
//add_to_log($course->id, 'project', 'readdescription', "view.php?id={$cm->id}&view=description&group={$currentGroupId}", 'export', $cm->id);
echo $OUTPUT->continue_button("view.php?view=description&id=$cm->id");
return;
}
/// Header editing form ********************************************************
if ($work == 'edit'){
if ($mform->is_cancelled()){
redirect($url);
}
if ($heading = $mform->get_data()){
$heading->abstract = $heading->abstract_editor['text'];
$heading->rationale = $heading->rationale_editor['text'];
$heading->environment = $heading->environment_editor['text'];
$abstract_draftid_editor = file_get_submitted_draft_itemid('abstract_editor');
$heading->abstract = file_save_draft_area_files($abstract_draftid_editor, $context->id, 'mod_project', 'abstract', $heading->id, array('subdirs' => true), $heading->abstract);
$rationale_draftid_editor = file_get_submitted_draft_itemid('rationale_editor');
$heading->rationale = file_save_draft_area_files($rationale_draftid_editor, $context->id, 'mod_project', 'rationale', $heading->id, array('subdirs' => true), $heading->rationale);
$environment_draftid_editor = file_get_submitted_draft_itemid('environment_editor');
$heading->environment = file_save_draft_area_files($environment_draftid_editor, $context->id, 'mod_project', 'environment', $heading->id, array('subdirs' => true), $heading->environment);
$heading->id = $heading->headingid;
$heading->projectid = $project->id;
$heading->groupid = $currentGroupId;
$heading->title = $heading->title;
$heading->organisation = $heading->organisation;
$heading->department = $heading->department;
$heading = file_postupdate_standard_editor($heading, 'abstract', $mform->editoroptions, $context, 'mod_project', 'absract', $heading->id);
$heading = file_postupdate_standard_editor($heading, 'rationale', $mform->editoroptions, $context, 'mod_project', 'rationale', $heading->id);
$heading = file_postupdate_standard_editor($heading, 'environment', $mform->editoroptions, $context, 'mod_project', 'environment', $heading->id);
$DB->update_record('project_heading', $heading);
redirect($url);
}
$projectheading = $DB->get_record('project_heading', array('projectid' => $project->id, 'groupid' => $currentGroupId));
// Start ouptuting here
echo $pagebuffer;
echo $OUTPUT->heading(get_string('editheading', 'project'));
$projectheading->headingid = $projectheading->id;
$projectheading->id = $cm->id;
$projectheading->format = FORMAT_HTML;
$projectheading->projectid = $project->id;
$mform->set_data($projectheading);
$mform->display();
} else {
// Start ouptuting here
echo $pagebuffer;
echo "<h2 class='titlecenter'>".$project->name."</h2>";
if(isset($project->commanditaire) && $project->commanditaire!=''){
echo "<p><b>Commanditaire du projet : </b><i>".$project->commanditaire."</i></p>";
}
echo "<div id='left-intro'><div id='desc-summary'><p style='font-weight:bold;'>".get_string('summary', 'project')." :</p>";
echo $project->intro."</div></div>";
echo "<div id='right-intro'>";
$fs = get_file_storage();
$files = $fs->get_area_files($context->id, 'mod_project', 'introimg', $project->id, 'sortorder DESC, id ASC', false);
//var_dump($files);
if(!empty($files)){
$file = reset($files);
//$url = moodle_url::make_pluginfile_url($context->id, 'project', 'introimg', $project->id, '', $imgFileName);
$path = '/'.$context->id.'/mod_project/introimg/'.$file->get_itemid().$file->get_filepath().$file->get_filename();
$url = moodle_url::make_file_url('/pluginfile.php', $path, '');
//echo "<img width='400' src='".file_encode_url($CFG->wwwroot . '/pluginfile.php', '/'.$context->id.'/mod_project/introimg/'.$project->introimg)."/".$imgFileName."' />";
//echo html_writer::link($url, $file->get_filename());
echo "<img style='max-width: 400px;' src='".file_encode_url($CFG->wwwroot . '/pluginfile.php', $path)."' />";
}
echo "</div><div id='sepbloc'></div>";
project_print_assignement_info($project, false);
// project_print_heading($project, $currentGroupId);
echo "<center>";
if ($USER->editmode == 'on' && has_capability('mod/project:addinstance', $context)) {
$files = $fs->get_area_files($context->id, 'mod_project', 'deliverablearchive', false, 'sortorder DESC, timemodified ASC', false);
if (!empty($files)) {
echo "<br/><a href=\"".project_export_last_deliverable($project)."\">".get_string('exportdeliv','project')."</a>";
}
/*
echo "<br/><a href=\"view.php?work=edit&id={$cm->id}\" >".get_string('editheading','project')."</a>";
echo " - <a href=\"view.php?work=doexport&id={$cm->id}\" >".get_string('exportheadingtoXML','project')."</a>";
*/
}
//echo "<br/><a href=\"xmlview.php?id={$cm->id}\" target=\"_blank\">".get_string('gettheprojectfulldocument','project')."</a>";
echo "</center>";
}