-
Notifications
You must be signed in to change notification settings - Fork 0
/
saimod_webcraft_gallery.php
91 lines (81 loc) · 5.78 KB
/
saimod_webcraft_gallery.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
<?php
class saimod_webcraft_gallery extends \SYSTEM\SAI\sai_module {
public static function getGalleryFlexslider($id){
$gallery = \SQL\SAIMOD_WEBCRAFT_GALLERY_GALLERY_ID::QQ(array($id));
$result = '<ul class="slides">';
while($img = $gallery->next()){
$result .= '<li><img class="img-responsive" src="./files/'.$img['file_cat'].'/'.$img['file_id'].'" alt="'.$img['description'].'"></li>';}
$result .= '</ul>';
return $result;
}
public static function sai_mod_saimod_webcraft_gallery_action_addgalleryitem($gallery, $position, $heading, $description, $file_cat, $file_id){
if(!\SQL\SAIMOD_WEBCRAFT_GALLERY_GALLERY_ITEM_ADD::QI(array($gallery, $position, $heading, $description, $file_cat, $file_id))){
throw new SYSTEM\LOG\ERROR("Problem with adding Galleryitem!");}
return \SYSTEM\LOG\JsonResult::ok();}
public static function sai_mod_saimod_webcraft_gallery_action_delgalleryitem($id){
if(!\SQL\SAIMOD_WEBCRAFT_GALLERY_GALLERY_ITEM_DELETE::QI(array($id))){
throw new SYSTEM\LOG\ERROR("Problem with deleting Galleryitem!");}
return \SYSTEM\LOG\JsonResult::ok();}
public static function sai_mod_saimod_webcraft_gallery_action_chggalleryitem($id, $gallery, $position, $heading, $description, $file_cat, $file_id){
if(!\SQL\SAIMOD_WEBCRAFT_GALLERY_GALLERY_ITEM_CHG::QI(array($gallery, $position, $heading, $description, $file_cat, $file_id, $id))){
throw new SYSTEM\LOG\ERROR("Problem with changing Galleryitem!");}
return \SYSTEM\LOG\JsonResult::ok();}
public static function sai_mod_saimod_webcraft_gallery_action_addgallery(){
$vars = array('file_cat_options' => self::select_options_cat(), 'file_id_options' => self::sai_mod_saimod_webcraft_gallery_action_select_options_id(array_keys(\SYSTEM\FILES\files::get())[0]));
return \SYSTEM\PAGE\replace::replaceFile((new PSAI('saimod_webcraft_gallery/tpl/saimod_webcraft_gallery_add.tpl'))->SERVERPATH(),$vars);
}
private static function select_options_cat($cat = null){
$result = '';
$cats = \SYSTEM\FILES\files::get();
foreach($cats as $name=>$path){
$selected = $name == $cat ? 'selected' : '';
$result .= \SYSTEM\PAGE\replace::replaceFile((new PSAI('saimod_webcraft_gallery/tpl/saimod_webcraft_gallery_file_option.tpl'))->SERVERPATH(), array('name' => $name, 'selected' => $selected));
}
return $result;
}
public static function sai_mod_saimod_webcraft_gallery_action_select_options_id($cat, $id = null){
$result = '';
$files = \SYSTEM\FILES\files::get($cat);
foreach($files as $file){
$selected = $file == $id ? 'selected' : '';
$result .= \SYSTEM\PAGE\replace::replaceFile((new PSAI('saimod_webcraft_gallery/tpl/saimod_webcraft_gallery_file_option.tpl'))->SERVERPATH(), array('name' => $file, 'selected' => $selected));
}
return $result;
}
public static function sai_mod_saimod_webcraft_gallery_action_showgalleryitem($gallery,$id){
$vars = \SQL\SAIMOD_WEBCRAFT_GALLERY_GALLERY_ITEM_ID::Q1(array($gallery,$id));
$vars = array_merge($vars, array('file_cat_options' => self::select_options_cat($vars['file_cat']), 'file_id_options' => self::sai_mod_saimod_webcraft_gallery_action_select_options_id($vars['file_cat'],$vars['file_id'])));
return \SYSTEM\PAGE\replace::replaceFile((new PSAI('saimod_webcraft_gallery/tpl/saimod_webcraft_gallery_show.tpl'))->SERVERPATH(),$vars);
}
public static function sai_mod_saimod_webcraft_gallery(){
$galleries = \SQL\SAIMOD_WEBCRAFT_GALLERY_GALLERIES::QQ();
$vars = array('tabopts' => '', 'firsttab' => '');
$first = true;
while($gallery = $galleries->next()){
$gallery['active'] = $first ? 'active' : '';
// if($first){$vars['firsttab'] = self::sai_mod_saimod_webcraft_gallery_action_tab($gallery['gallery']);}
$first = false;
$vars['tabopts'] .= \SYSTEM\PAGE\replace::replaceFile((new PSAI('saimod_webcraft_gallery/tpl/saimod_webcraft_gallery_tabopt.tpl'))->SERVERPATH(), $gallery);}
return \SYSTEM\PAGE\replace::replaceFile((new PSAI('saimod_webcraft_gallery/tpl/saimod_webcraft_gallery_tabs.tpl'))->SERVERPATH(),$vars);
}
public static function sai_mod_saimod_webcraft_gallery_action_tab($name = 1){
$gallery = \SQL\SAIMOD_WEBCRAFT_GALLERY_GALLERY_ID::QQ(array($name));
$content = '';
while($entry = $gallery->next()){
$content .= \SYSTEM\PAGE\replace::replaceFile((new PSAI('saimod_webcraft_gallery/tpl/saimod_webcraft_gallery_tabentry.tpl'))->SERVERPATH(), $entry);}
return \SYSTEM\PAGE\replace::replaceFile((new PSAI('saimod_webcraft_gallery/tpl/saimod_webcraft_gallery_tab.tpl'))->SERVERPATH(),
array('content' => $content, 'gallery' => self::getGalleryFlexslider($name)));
}
public static function menu(){
return new \SYSTEM\SAI\sai_module_menu( 1,
\SYSTEM\SAI\sai_module_menu::POISITION_RIGHT,
\SYSTEM\SAI\sai_module_menu::DIVIDER_NONE,
\SYSTEM\PAGE\replace::replaceFile((new PSAI('saimod_webcraft_gallery/tpl/menu.tpl'))->SERVERPATH()));}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function js(){
return array( \LIB\lib_flexslider::js(),
new PSAI('saimod_webcraft_gallery/js/saimod_webcraft_gallery.js'));}
public static function css(){
return array( \LIB\lib_flexslider::css());}
}