This repository was archived by the owner on Dec 7, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreat_gallery.php
More file actions
179 lines (162 loc) · 5.3 KB
/
creat_gallery.php
File metadata and controls
179 lines (162 loc) · 5.3 KB
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
require_once 'autoload.php';
// Check for accses
User::CheckLogin();
$Gallery = new Gallery();
$access = User::getSessionAccses();
if (!$Gallery->hasAccsesToModify($access)) {
header("Location: accses_denied.php");
}
// Update
if (isset($_GET["id"])) {
if ($Gallery->read($_GET["id"])) {
$Data = array(
"title_en" => $Gallery->getTitleEnglish(),
"title_ar" => $Gallery->getTitleArabic()
);
$Gallery->setImageNumber(1);
} else {
header("Location: 404.php");
exit;
}
}
if (valAllNotnull()) {
// setting the data
$iscorrect = array(
"title_en" => (bool) $Gallery->setTitleEnglish($_POST["title_en"]),
"title_ar" => (bool) $Gallery->setTitleArabic($_POST["title_ar"])
);
// set the publish or aprove or creat
$Gallery->setDisplayFromSession($access);
$passed = FALSE;
// check if the imput is valid
if (Validation::valAll($iscorrect)) {
if (isset($_GET["id"])) {
$passed = (bool) $Gallery->update();
if ($passed) {
$x = new Updates;
$x->setEditorID(User::getSessionUserID());
$x->setTargetType(Updates::TARGET_TYPE_GALLERY);
$x->setTargetID($Gallery->getId());
$x->setMessageType(Updates::MESSAGE_TYPE_UPDATE);
$x->create();
$y = new Notification;
$y->setUserID($Gallery->getWriterID());
$y->setSource(Notification::SOURCE_GALLERY);
$y->setsourceID($Gallery->getId());
$y->setMessage("Gallery was updated succsesfuly");
$y->create();
}
} else {
$Gallery->setWriterID(User::getSessionUserID());
$Gallery->setImageNumber(1);
$passed = (bool) $Gallery->create();
rename("images\\gallery\\upload.jpg", "images\\gallery\\" . $Gallery->getId() . "-0.jpg");
}
}
// check if every thing went right
if ($passed) {
header("Location: gallery.php");
exit;
} else {
$Data = array(
"title_en" => $_POST["title_en"],
"title_ar" => $_POST["title_ar"]
);
}
}
function valAllNotnull() {
return
isset($_POST["title_en"]) &&
isset($_POST["title_ar"]);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>ACU Times | Creat Article</title>
<?php require_once("header.php"); ?>
<link rel="stylesheet" href="css/dropezone.css" type="text/css" media="all">
<script src='js/tinymce/tinymce.min.js'></script>
<script src="js/dropzone.js"></script>
<script src="js/Validate.js"></script>
</head>
<body onLoad="onLoad()">
<?php include ("navbar.php"); ?>
<div class="container">
<h3>
<ul class="nav nav-pills">
<li role="presentation"><a href="creat_article.php"> Article </a></li>
<li role="presentation"><a href="creat_poll.php"> Poll </a></li>
<li role="presentation"><a href="creat_multimedia.php"> Multimedia </a></li>
<li role="presentation" class="active"><a> Gallery </a></li>
</ul>
</h3>
<br><br>
<form class="form-horizontal" role="form" method="post" action="creat_gallery.php<?php if (isset($_GET["id"])) echo "?id=" . $_GET["id"] ?>">
<!-- #################################################################### Title-EN #################################################################### -->
<div class="form-group">
<label class="control-label col-sm-2" for="title_en">Title English :</label>
<div class="controls col-sm-10">
<input type="text"
name="title_en"
id="title_en"
value="<?php echo @$Data["title_en"]; ?>"
placeholder="Enter title in English"
class="form-control"
onBlur="valTitle(this)"
maxlength="128"
required
autocomplete="on">
<span class="help-block">
<ul>
<?php PrintHTML::validation("title_en", @$iscorrect["title_en"], "Invalid Input") ?>
</ul>
</span></div>
</div>
<!-- #################################################################### Title-AR #################################################################### -->
<div class="form-group">
<label class="control-label col-sm-2" for="title_ar">Title Arabic :</label>
<div class="controls col-sm-10">
<input type="text"
name="title_ar"
id="title_ar"
value="<?php echo @$Data["title_ar"]; ?>"
placeholder="Enter title in arabic"
class="form-control"
onBlur="valTitle(this)"
maxlength="128"
required
autocomplete="on">
<span class="help-block">
<ul>
<?php PrintHTML::validation("title_ar", @$iscorrect["title_ar"], "Invalid Input") ?>
</ul>
</span></div>
</div>
<!-- #################################################################### DropZone #################################################################### -->
<br>
<div class="form-group">
<div class="dropzone " id="upload-widget"> </div>
<input type="hidden" name="IMG" id ="IMG">
</div>
<button type="submit" class="btn btn-primary pull-right">Submit</button>
</form>
</div>
<?php include ("footer.php"); ?>
<script>
var cleanFilename = function (name) {
//document.getElementById("IMG").value = name;
return name.toLowerCase().replace(/^[\w.]+$/i, 'upload.jpg');
};
var myDropzone = new Dropzone("div#upload-widget", {
url: "uploadGallery.php",
maxFilesize: 4,
maxFiles: 1,
parallelUploads: 1,
acceptedFiles: "image/*",
renameFilename: cleanFilename
});
</script>
</body>
</html>