-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharticles.php
executable file
·783 lines (680 loc) · 30 KB
/
articles.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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
<?php
require_once('database.php');
require_once('metatag.php');
require_once('category.php');
require_once('publish.php');
require_once('images.php');
require_once('jobstypes.php');
require_once('universitystudy.php');
class articles {
private $id;
private $title;
private $intro;
private $text;
private $image;
private $category; private $ctg;
private $comments;
private $editable;
private $views;
private $publish; private $pbls;
private $gallery; private $gall;
private $metatags;private $mtg;
private $date_of;
private $deleted;
private $selected_article;
private $jobtype;private $jobtype_id;
private $scolarship_id;private $scolarship;
private $status;
private $user;
private $type;
public function __construct(){
$this->ctg= new category();$this->category=0;
$this->pbls= new publish();$this->publish=0;
$this->mtg= new metatag();$this->metatags=0;
$this->gallery=0;
$this->jobtype= new jobstypes();$this->jobtype_id=0;
$this->scolarship= new universitystudy();$this->scolarship_id=0;
$this->image=new images();
}
public function load_from_post($p){
$this->title=addslashes($p['article_title']);
$this->intro=addslashes(strip_tags($p['article_intro_txt'],'<p><strong><span><em><ul><li><ol>'));
$this->text=addslashes(strip_tags($p['article_main_txt'],'<p><strong><span><em><ul><li><ol><hr><sup><object><param><embed><a>'));
$this->id=@$p['article_id'];
$this->type=$p['article_type'];
}
public function select_article($article_id){
$this->selected_article=$article_id;
}
public function load_article($article_id){
$db= new database();
$sql="SELECT * FROM `articles` as m WHERE m.ID='".$article_id."'";
list($result,$a)=$db->query($sql);
if($result && mysql_num_rows($result)>0){
while ($podaci = mysql_fetch_array($result)){
$this->id=$podaci['ID'];
$this->title=$podaci['title'];
$this->intro=$podaci['intro'];
$this->text=$podaci['tekst'];
$this->image=$podaci['image'];
$this->category=$podaci['category'];
$this->comments=$podaci['comments'];
$this->editable=$podaci['editable'];
$this->views=$podaci['views'];
$this->publish=$podaci['publish'];
$this->gallery=$podaci['gallery'];
$this->metatags=$podaci['metatags'];
$this->jobtype_id=$podaci['jobtype'];
$this->date_of=$podaci['date_of_creation'];
$this->deleted=$podaci['deleted'];
$this->user=$podaci['user'];
$this->status=$podaci['status'];
$this->scolarship_id=$podaci['scolarship'];
$this->user_type=$podaci['user_type'];
};
};
if($this->scolarship_id==-1 && $this->jobtype_id==-1) $this->type='news';
if($this->scolarship_id==-1 && $this->jobtype_id!=-1) $this->type='job';
if($this->jobtype_id==-1 && $this->scolarship_id!=-1) $this->type='scolarship';
}
public function save_to_database(){
$db= new database();
//$this->load_from_post($_POST);
$db->open_connection();
$this->ctg->load_from_post($_POST);
$this->pbls->load_from_post($_POST);
$this->jobtype->load_from_post($_POST);
$this->scolarship->load_from_post($_POST);
$this->category=@$_POST['article_category'];
$this->image->load_from_post(@$_POST);
$this->gallery=$_POST['article_gallery'];
$this->publish=$this->pbls->save_to_database();
//$this->metatags=$this->mtg->save_to_database();
if($this->type=='intership' || $this->type=='job' ){ $this->jobtype_id=$this->jobtype->save_to_database(); } else { $this->jobtype_id=-1; };
if($this->type=='scolarship') { $this->scolarship_id=$this->scolarship->save_to_database(); } else {$this->scolarship_id=-1;};
$sql="INSERT INTO `articles` VALUES(NULL,'".htmlentities($this->title)."','".$this->intro."','".$this->text."','".$this->image->getimage()."','".$this->category."','".$this->comments."','".$this->editable."','0','".$this->publish."','".$this->gallery."','".$this->metatags."','".$this->jobtype_id."','".$this->scolarship_id."','Pending','".$_SESSION['id']."','".$_SESSION['rank']."',NOW(),0)";
$db->query($sql);
}
public function update_to_database(){
$db= new database();
$db->open_connection();
//$this->load_from_post($_POST);
$this->ctg->load_from_post($_POST);
$this->pbls->load_from_post($_POST);
//$this->mtg->load_from_post($_POST);
//$this->gall->load_from_post($_POST);
$this->category=$_POST['article_category'];
$this->gallery=$_POST['article_gallery'];
$this->pbls->update_to_database();
//$this->mtg->update_to_database();
if(isset($_POST['article_edit_thumb_change'])=='yes'){
$this->image->load_from_post($p);
//echo $this->category;
$im="image='".addslashes($this->image->getimage())."', ";
}
else $im="";
if($this->jobtype_id!=-1){
$this->jobtype->load_from_post($_POST);
$this->jobtype->update_to_database();
}
if($this->scolarship_id!=-1){
$this->scolarship->load_from_post($_POST);
$this->scolarship->update_to_database();
}
$sql="UPDATE `articles` SET title='".htmlentities($this->title)."', intro='".$this->intro."', tekst='".$this->text."', ".$im." category='".$this->category."' WHERE ID='".$this->id."'";
$db->query($sql);
}
public function show_article_form($typ='news'){
//$ctg= new category();
//$pbls=new publish();
$db=new database();
$db->open_connection();
@$number;
$s="SELECT number FROM posts WHERE type='".$_SESSION['rank']."' AND type_id='".$_SESSION['id']."'";
$res=mysql_query($s);
while(@$row= mysql_fetch_array($res)){
$number=$row['number'];
}
echo '';
if($number>0){
echo'<br><br>
<h3> You have '.$number.' more articles to add.</h3>';
}
else{
echo '<h2>You have '.$number.' articles to add. Contact Administrator if you want to extend the number of announcments.</h2>';
}
$this->ctg->choose_category($this->category);
$this->pbls->load_publish($this->publish);
//$this->mtg->load_metatags($this->metatags);
$this->jobtype->load_jobtype($this->jobtype_id);
$this->scolarship->load_universitystudy($this->scolarship_id);
echo ('<form action="index.php" method="post" enctype="multipart/form-data" name="form_article" id="form_article" class="addarticlesform">
<h2>Article Manager: Add Article</h2>
<label><strong>Title</strong></label>
<input name="article_type" type="hidden" id="article_type" value="'.$typ.'">
<input name="article_title" type="text" id="article_title" value="'.$this->title.'"/>
<label>Intro</label>
<textarea name="article_intro_txt" cols="100" rows="5" id="article_intro_txt" style="width:98%" >'.$this->intro.'</textarea>
<label>Text </label>
<textarea name="article_main_txt" cols="100" rows="30" id="article_main_txt" style="width:98%">'.$this->text.'</textarea>
<script type="text/javascript" src="js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
// General options
//mode : "textareas",
theme : "advanced",
plugins : "youtube,safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",
mode : "exact",
elements : "article_main_txt",
relative_urls: false,
remove_script_host : false,
// Theme options
theme_advanced_buttons1 : "bold,italic,underlitheme_advanced_buttonsne,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontsizeselect",
theme_advanced_buttons2 : "search,replace,|,bullist,numlist,|,link,unlink,code,media",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : false,
// Example content CSS (should be your site CSS)
content_css : "css/content.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
tinyMCE.init({
// General options
//mode : "textareas",
theme : "simple",
plugins : "youtube,safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",
mode : "exact",
elements : "article_intro_txt",
relative_urls: false,
remove_script_host : false,
// Theme options
theme_advanced_layout_manager : "SimpleLayout",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// Example content CSS (should be your site CSS)
content_css : "css/content.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
</script>
<br>
<label>Intro image</label>
<input type="file" name="image" id="image" />
');
if($typ=='intership' || $typ=='job'){
$this->jobtype->set_type($typ);
echo '
<h3>Internships/Job deteails</h3>';
$this->jobtype->show_publish_form();
}
if($typ=='scolarship'){
echo '
<h3>Scholarship</h3>';
$this->scolarship->show_publish_form();
}
echo '
<h3>Publish</h3>';
$this->pbls->show_publish_form();
echo('
<input type="submit" name="article_save" class="btn" value="" onclick="toastr.info(\'Article added, but it needs to be approved by Administrator.\')" />
</form>
');
}
public function show_article_form_edit($typ='news'){
//$ctg= new category();
//$pbls=new publish();
$this->ctg->choose_category($this->category);
$this->pbls->load_publish($this->publish);
//$this->mtg->load_metatags($this->metatags);
$this->jobtype->load_jobtype($this->jobtype_id);
$this->scolarship->load_universitystudy($this->scolarship_id);
echo ('<form action="index.php" method="post" enctype="multipart/form-data" name="form" id="form" class="addarticlesform">
<h3>Article Manager: Edit Article </h3>
<label>Title</label>
<input name="article_title" type="text" id="article_titl" value="'.str_replace('"','\"',$this->title).'"/>
<input name="article_id" type="text" id="article_id" style="visibility:hidden" value="'.$this->id.'"/>
<input name="article_type" type="hidden" id="article_type" value="'.$this->type.'">
<label>Intro</label>
<textarea name="article_intro_txt" cols="100" rows="5" id="article_intro_txt" style="width:98%">'.$this->intro.'</textarea>
<label>Text </label>
<textarea name="article_main_txt" cols="100" rows="30" id="article_main_txt" style="width:98%">'.$this->text.'</textarea>
<script type="text/javascript" src="js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
// General options
//mode : "textareas",
theme : "advanced",
plugins : "youtube,safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",
mode : "exact",
elements : "article_main_txt",
relative_urls: false,
remove_script_host : false,
// Theme options
theme_advanced_buttons1 : "bold,italic,underlitheme_advanced_buttonsne,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontsizeselect,search,replace",
theme_advanced_buttons2 : "bullist,numlist,|,link,unlink,code,media,youtube",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// Example content CSS (should be your site CSS)
content_css : "css/content.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
tinyMCE.init({
// General options
//mode : "textareas",
theme : "simple",
plugins : "youtube,safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",
mode : "exact",
elements : "article_intro_txt",
document_base_url : "",
relative_urls: false,
remove_script_host : false,
// Theme options
theme_advanced_layout_manager : "SimpleLayout",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// Example content CSS (should be your site CSS)
content_css : "css/content.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
</script>
<br>
<label><strong>Intro image</strong></label><br><br>
<label>Change picture</label> <input type="checkbox" value="yes" name="article_edit_thumb_change"> <input type="file" name="image" id="image" />
<br>');
//$this->ctg->show_category_form();
if($this->type=='intership' || $this->type=='job'){
echo '
<h3>Internships/Jobs deteails</h3>';
$this->jobtype->show_publish_form();
}
if($this->type=='scolarship'){
echo '
<h3>Scholarship</h3>';
$this->scolarship->show_publish_form();
}
$this->pbls->show_publish_form();
//$this->mtg->show_metatag_form();
echo '
<input type="submit" name="article_edit" class="btn" value="" onclick="toastr.success(\'Your article is updated now.\')"/>
</form>
';
}
public function manage_article_selected_changes(){
$db= new database();
if($_POST['article_list_todo']=='delete'){
$sql="UPDATE `articles` SET deleted=1 WHERE";
$p=1;
//$sql="DELETE FROM `kategorija` WHERE ";
foreach ($_POST['select'] as $vrijednost) {
if ($p<count($_POST['select'])) {
$sql=$sql." ID='".$vrijednost."' OR ";
} else {
$sql=$sql." ID='".$vrijednost."' ";
};
$p=$p+1;
};
$p=$p-1;
$sql=$sql." LIMIT ".$p;
$db->query($sql);
}
if($_POST['article_list_todo']=='publish'){
$sql="UPDATE `publish_articles` AS p, `articles` AS a SET p.status='publish' WHERE";
$p=1;
//$sql="DELETE FROM `kategorija` WHERE ";
foreach ($_POST['select'] as $vrijednost) {
if ($p<count($_POST['select'])) {
$sql=$sql." (a.ID='".$vrijednost."' AND p.ID=a.publish) OR ";
} else {
$sql=$sql." (a.ID='".$vrijednost."' AND p.ID=a.publish) ";
};
$p=$p+1;
};
$p=$p-1;
//$sql=$sql." LIMIT ".$p;
$db->query($sql);
}
if($_POST['article_list_todo']=='unpublish'){
$sql="UPDATE `publish_articles` AS p, `articles` AS a SET p.status='unpublish' WHERE";
$p=1;
//$sql="DELETE FROM `kategorija` WHERE ";
foreach ($_POST['select'] as $vrijednost) {
if ($p<count($_POST['select'])) {
$sql=$sql." (a.ID='".$vrijednost."' AND p.ID=a.publish) OR ";
} else {
$sql=$sql." (a.ID='".$vrijednost."' AND p.ID=a.publish) ";
};
$p=$p+1;
};
$p=$p-1;
//$sql=$sql." LIMIT ".$p;
$db->query($sql);
}
if($_POST['article_list_todo']=='draft'){
$sql="UPDATE `publish_articles` AS p, `articles` AS a SET p.status='draft' WHERE";
$p=1;
//$sql="DELETE FROM `kategorija` WHERE ";
foreach ($_POST['select'] as $vrijednost) {
if ($p<count($_POST['select'])) {
$sql=$sql." (a.ID='".$vrijednost."' AND p.ID=a.publish) OR ";
} else {
$sql=$sql." (a.ID='".$vrijednost."' AND p.ID=a.publish) ";
};
$p=$p+1;
};
$p=$p-1;
//$sql=$sql." LIMIT ".$p;
$db->query($sql);
}
}
public function show_management_list($status=""){
$db= new database();
if($status=='published') $status=" p.status='publish' AND";
if($status=='unpublished') $status=" p.status='unpublish' AND";
if($status=='draft') $status=" p.status='draft' AND";
if($status=='user') $status=" user='".$_SESSION['id']."' AND user_type='".$_SESSION['rank']."' AND ";
$sql="SELECT a.ID,a.title,a.deleted,p.status as publish,a.status,a.date_of_creation,a.views,a.jobtype,a.scolarship FROM articles AS a, publish_articles AS p WHERE ".$status." a.deleted=0 AND a.publish=p.ID ORDER BY a.ID DESC";
list($result,$a)=$db->query($sql);
echo('<form action="index.php" method="post" enctype="multipart/form-data" name="form" id="form" class="studentform">
<h3>Article Manager: Article list </h3>
<table border="0"><tr><p>
<td></td>
<td > <div align="center"><strong>Title</strong></div></td>
<td ><div align="center"><strong>Type</strong></div></td>
<td ><div align="center"><strong>Status</strong></div></td>
<td ><div align="center"><strong>Views</strong></div></td>
<td ><div align="center"><strong>Date</strong></div></td>
</tr>');
if($result && mysql_num_rows($result)>0){
$i=0;
while ($podaci = mysql_fetch_array($result)){
if($i % 2==0){ $class="article_management_first_line" ; } else { $class="article_management_scnd_line"; }
if($podaci['publish']=='publish') $status='Published';
if($podaci['publish']=='unpublish') $status='Unpublished';
if($podaci['publish']=='draft') $status='Draft';
if($podaci['status']=='Pending') $status1='Pending';
if($podaci['status']=='Active') $status1='Active';
if($podaci['deleted']==0) $deleted='<img src="graphics/icons/remove_24x24.png" width="16" heigth="16">';
if($podaci['deleted']==1) $deleted='<img src="graphics/icons/check_24x24.png" width="16" heigth="16">';
if($podaci['jobtype']!=-1 && $podaci['scolarship']==-1) $type='Job/Intership';
if($podaci['jobtype']==-1 && $podaci['scolarship']!=-1) $type='Master/PhD';
if($podaci['jobtype']==-1 && $podaci['scolarship']==-1) $type='News';
echo('<tr>
<td><div align="center">
<input type="checkbox" name="select[]" id="select" value="'.$podaci['ID'].'"/>
</div></td>
<td><a href="?do=edit_article&article_id='.$podaci['ID'].'">'.substr($podaci['title'],0,28).'..</a></td>
<td align="center">'.$type.'</td>');
if($status1=="Active")
echo '<td><div align="center">'.$status.'</div></td>';
else
echo '<td><div align="center">'.$status1.'</div></td>';
echo ('<td><div align="center">'.$podaci['views'].'</div></td>
<td><div align="center">'.date_format(date_create($podaci['date_of_creation']),"d.m.y") .'</div></td>
</tr>');
$i++;
}
}
echo('<tr>
<td colspan="7">
<div id="article_form_buttons" align="left"><br />
With selected <select name="article_list_todo" id="article_list_todo" style="width:30%">
<option value="publish">Publish</option>
<option value="draft">Draft</option>
<option value="delete">Delete</option></select>
<input type="submit" name="article_submit_list" id="article_submit_list" class="btn" value="" />
</div></td></p>
</tr>
</table>
</form>
</div>');
}
public function show_sidemenu_article_panel(){
echo '
<div id="article_mini_menu">
<div class="plugin_menu_box_main_container_header">Article Manager</div>
<table width="98%" border="0" cellpadding="3" cellspacing="2" class="plugin_menu_box_main_container">
<tr>
<td><a href="?menu=article&do=add_article"><img src="graphics/icons/Article_24x24.png" align="absmiddle"/>Add Article</a></td>
</tr>
<tr>
<td><a href="?menu=article&do=show_article"><img src="graphics/icons/text-edit_24x24.png" align="absmiddle"/>Edit Article</a></td>
</tr>
<tr>
<td><a href="?menu=article&do=show_article"><img src="graphics/icons/recycle_24x24.png" align="absmiddle"/>Delete Article</a></td>
</tr>
<tr>
<td><a href="?menu=article&do=add_category"><img src="graphics/icons/add_24x24.png" align="absmiddle"/>Add Category</a></td>
</tr>
<tr>
<td><a href="?menu=article&do=list_category"><img src="graphics/icons/edit_24x24.png" align="absmiddle"/>Rename Category</a></td>
</tr>
<tr>
<td><a href="?menu=article&do=list_category"><img src="graphics/icons/delete_24x24.png" align="absmiddle"/>Delete Category</a></td>
</tr>
</table>
</div>
';
}
// stats for this module
public function stats_all_articles(){
$db= new database();
echo('
<div id="article_stats_all_articles" align="center">
<div align="left"><b>Articles stats</b></div>
<table width="100%" border="0" cellpadding="2" cellspacing="1">
<tr>
<td width="0%"> <div align="left">Status</div></td>
<td width="90px"><div align="center">Articles</div></td>
<td width="80px"><div align="center">Reads</div></td>
</tr>');
$sql="SELECT p.status,COUNT(a.ID),SUM(a.views) FROM articles AS a,publish_articles AS p WHERE a.publish=p.ID AND a.deleted=0 GROUP BY p.status ORDER BY p.status";
list($result,$a)=$db->query($sql);
if($result && mysql_num_rows($result)>0){
$i=0;
while ($podaci = mysql_fetch_array($result)){
if($i % 2==0){ $class="article_management_first_line" ; } else { $class="article_management_scnd_line"; }
if($podaci['status']=='publish') $status='<img src="graphics/icons/check_24x24.png" width="16" heigth="16"> Published';
if($podaci['status']=='unpublish') $status='<img src="graphics/icons/analysis16.png" width="16" heigth="16"> Unpublished';
if($podaci['status']=='draft') $status='<img src="graphics/icons/tests16.png" width="16" heigth="16"> Draft';
echo('<tr class="'.$class.'">
<td>'.$status.'</td>
<td><div align="center">'.$podaci['COUNT(a.ID)'].'</div></td>
<td><div align="center">'.$podaci['SUM(a.views)'].'</div></td>
</tr>');
$i++;
}
}
echo('</table>
</div>
');
}
public function stats_last_published_articles($num=5){
$db= new database();
echo('
<div id="article_stats_all_articles" align="center">
<div align="left"><b>Last published articles</b></div>
<table width="100%" border="0" cellpadding="2" cellspacing="1">
<tr>
<td width="0%"> <div align="left">Title</div></td>
<td width="80px"><div align="center">Reads</div></td>
</tr>');
$sql="SELECT a.title,a.views FROM articles AS a,publish_articles AS p WHERE p.status='publish' AND a.publish=p.ID AND a.deleted=0 ORDER BY a.ID DESC LIMIT ".$num;
list($result,$a)=$db->query($sql);
if($result && mysql_num_rows($result)>0){
$i=0;
while ($podaci = mysql_fetch_array($result)){
if($i % 2==0){ $class="article_management_first_line" ; } else { $class="article_management_scnd_line"; }
echo('<tr class="'.$class.'">
<td>'.$podaci['title'].'</td>
<td><div align="center">'.$podaci['views'].'</div></td>
</tr>');
$i++;
}
}
echo('</table>
</div>
');
}
public function stats_last_unpublished_articles($num=5){
$db= new database();
echo('
<div id="article_stats_all_articles" align="center">
<div align="left"><b>Last unpublished articles</b></div>
<table width="100%" border="0" cellpadding="2" cellspacing="1">
<tr>
<td width="0%"> <div align="left">Title</div></td>
<td width="80px"><div align="center">Reads</div></td>
</tr>');
$sql="SELECT a.title,a.views FROM articles AS a,publish_articles AS p WHERE p.status='unpublish' AND a.publish=p.ID AND a.deleted=0 ORDER BY a.ID DESC LIMIT ".$num;
list($result,$a)=$db->query($sql);
if($result && mysql_num_rows($result)>0){
$i=0;
while ($podaci = mysql_fetch_array($result)){
if($i % 2==0){ $class="article_management_first_line" ; } else { $class="article_management_scnd_line"; }
echo('<tr class="'.$class.'">
<td>'.$podaci['title'].'</td>
<td><div align="center">'.$podaci['views'].'</div></td>
</tr>');
$i++;
}
}
echo('</table>
</div>
');
}
public function stats_last_draft_articles($num=5){
$db= new database();
echo('
<div id="article_stats_all_articles" align="center">
<div align="left"><b>Last draft articles</b></div>
<table width="100%" border="0" cellpadding="2" cellspacing="1">
<tr>
<td width="0%"> <div align="left">Title</div></td>
<td width="80px"><div align="center">Reads</div></td>
</tr>');
$sql="SELECT a.title,a.views FROM articles AS a,publish_articles AS p WHERE p.status='draft' AND a.publish=p.ID AND a.deleted=0 ORDER BY a.ID DESC LIMIT ".$num;
list($result,$a)=$db->query($sql);
if($result && mysql_num_rows($result)>0){
$i=0;
while ($podaci = mysql_fetch_array($result)){
if($i % 2==0){ $class="article_management_first_line" ; } else { $class="article_management_scnd_line"; }
echo('<tr class="'.$class.'">
<td>'.$podaci['title'].'</td>
<td><div align="center">'.$podaci['views'].'</div></td>
</tr>');
$i++;
}
}
echo('</table>
</div>
');
}
public function stats_moast_readed_articles($num=5){
$db= new database();
echo('
<div id="article_stats_all_articles" align="center">
<div align="left"><b>Moast viewed articles</b></div>
<table width="100%" border="0" cellpadding="2" cellspacing="1">
<tr>
<td width="0%"> <div align="left">Title</div></td>
<td width="80px"><div align="center">Reads</div></td>
</tr>');
$sql="SELECT a.title,a.views FROM articles AS a,publish_articles AS p WHERE a.publish=p.ID AND a.deleted=0 ORDER BY a.views DESC LIMIT ".$num;
list($result,$a)=$db->query($sql);
if($result && mysql_num_rows($result)>0){
$i=0;
while ($podaci = mysql_fetch_array($result)){
if($i % 2==0){ $class="article_management_first_line" ; } else { $class="article_management_scnd_line"; }
echo('<tr class="'.$class.'">
<td>'.$podaci['title'].'</td>
<td><div align="center">'.$podaci['views'].'</div></td>
</tr>');
$i++;
}
}
echo('</table>
</div>
');
}
public function show_article_listbox($status=""){
$db= new database();
if($status=='published') $status=" p.status='publish' AND";
if($status=='unpublished') $status=" p.status='unpublish' AND";
if($status=='draft') $status=" p.status='draft' AND";
$sql="SELECT a.ID,a.title FROM articles AS a,publish_articles AS p WHERE ".$status." a.deleted=0 AND a.publish=p.ID ORDER BY a.ID DESC";
list($result,$a)=$db->query($sql);
if($result && mysql_num_rows($result)>0){
echo '<select name="article_select" id="article_select" style="width:60%">';
while ($podaci = mysql_fetch_array($result)){
if($podaci['ID']==$this->selected_article){
echo('<option value="'.$podaci['ID'].'" selected="selected">'.$podaci['title'].'</option>');
} else {
echo('<option value="'.$podaci['ID'].'">'.$podaci['title'].'</option>');
}
}
echo '</select>';
}
}
}
//ubaciti dio koji provjerava get varijable 'akcija' i u zavisnosti od nje poziva funkciju po potrebi
/*if($_GET['do']=='add_article'){
$add_article= new articles();
$add_article->show_article_form();
}*/
if(isset($_POST['article_save'])) {
$add_article= new articles();
$add_article->load_from_post(@$_POST);
$add_article->save_to_database();
}
if(isset($_POST['article_edit'])) {
$add_article= new articles();
$add_article->load_from_post($_POST);
$add_article->update_to_database();
}
if(isset($_POST['article_submit_list'])) {
$add_article= new articles();
$add_article->manage_article_selected_changes();
}
?>