24
31
function getExamples($cid) {
25
$query = $this->db->get_where('examples', array("cid" => $cid));
32
$query = $this->db->get_where('examples', array("Courses_courseID" => $cid));
26
33
return $query->result();
29
function addExample($cid, $example){
36
function addExample($cid, $example, $description){
38
'Courses_courseID' => $cid ,
40
'description' => $description
35
43
$this->db->insert('examples', $data);
36
44
mkdir("../courses/".$cid."/".$example);
40
48
function getPages($cid, $example) {
41
$query = $this->db->get_where('pages', array("cid" => $cid, "example" => $example));
49
$query = $this->db->get_where('pages', array("Examples_Courses_courseID" => $cid, "Examples_Name" => $example));
42
50
return $query->result();
45
function addPage($cid, $example, $page, $documentation){
53
function addPage($cid, $example, $page){
48
'example' => $example,
50
'documentation' => $documentation
55
'Examples_Courses_courseID' => $cid ,
56
'Examples_Name' => $example,
53
60
$this->db->insert('pages', $data);
54
61
mkdir("../courses/".$cid."/".$example."/".$page);
64
'fileName' => $cid."/".$example."/".$page."/documentation",
65
'language' => $file->lang,
66
'fileType' => $file->type,
70
$this->db->insert('files', $data);
73
'Files_fileName' => $cid."/".$example."/".$page."/documentation" ,
74
'Pages_name' => $page,
75
'Pages_Examples_Name' => $example,
76
'Pages_Examples_Courses_courseID' => $cid
79
$this->db->insert('pagesfiles', $data);
58
function updatePage($cid, $example, $page, $documentation){
83
function updatePage($cid, $example, $page, $documentation, $files){
85
$filearr = json_decode($files);
87
foreach ($filearr as $file) {
89
$handle = @fopen("../courses/".$cid."/".$example."/".$page."/".$file->filename, "r");
92
while (($buffer = fgets($handle, 4096)) !== false) {
94
$buffer = str_replace("&", "&", $buffer);
95
$buffer = str_replace("<", "<", $buffer);
96
$buffer = str_replace(">", ">", $buffer);
100
if (!feof($handle)) {
101
$output .= "Error: unexpected fgets() fail\n";
107
'fileName' => $file->filename ,
108
'language' => $file->lang,
109
'fileType' => $file->type,
110
'dataBlob' => $output
113
$this->db->insert('files', $data);
116
'Files_fileName' => $file->filename ,
117
'Pages_name' => $page,
118
'Pages_Examples_Name' => $example,
119
'Pages_Examples_Courses_courseID' => $cid
122
$this->db->insert('pagesfiles', $data);
60
'documentation' => $documentation
63
$this->db->where('cid', $cid);
64
$this->db->where('example', $example);
65
$this->db->where('page', $page);
66
$this->db->update('pages', $data);
126
'dataBlob' => $documentation
129
$this->db->where("fileName",$cid."/".$example."/".$page."/"."documentation" );
130
$this->db->update('files', $data);
69
135
function uploadFile($files, $cid, $example, $page){