This repository has been archived by the owner on Jun 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.php
205 lines (174 loc) · 5.83 KB
/
view.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
<?php
/**
* @module foldergallery
* @version see info.php of this module
* @author cms-lab (initiated by Jürg Rast)
* @copyright 2010-2018 cms-lab
* @license GNU General Public License
* @license terms see info.php of this module
* @platform see info.php of this module
*
*/
// include class.secure.php to protect this file and the whole CMS!
if (defined('LEPTON_PATH')) {
include(LEPTON_PATH.'/framework/class.secure.php');
} else {
$oneback = "../";
$root = $oneback;
$level = 1;
while (($level < 10) && (!file_exists($root.'/framework/class.secure.php'))) {
$root .= $oneback;
$level += 1;
}
if (file_exists($root.'/framework/class.secure.php')) {
include($root.'/framework/class.secure.php');
} else {
trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
}
}
// end include class.secure.php
$oFGF = foldergallery_frontend::getInstance();
$oFGF->init_frontend_page($page_id, $section_id);
LEPTON_handle::include_files ( '/modules/foldergallery/backend.functions.php');
$oTWIG = lib_twig_box::getInstance();
$oTWIG->registerModule('foldergallery');
// Foldergallery settings
$settings = $oFGF->fg_settings;
$thumb_size = $settings['thumb_size'];
$root_dir = $settings['root_dir'];
$catpic = (int) $settings['catpic'];
$ratio = $settings['ratio'];
// Build the category tree
/*
$aCatTree = array();
$oFGF->buildCatTree( 0, $aCatTree, 0);
echo (LEPTON_tools::display( $aCatTree ,'pre','ui message'));
return 0; // No "die" - we just exit here (in this __FILE__ and keep the current process going on ..
*/
$result = array();
$subCat = array();
$images = array();
$error = false;
$title = PAGE_TITLE;
// only subpages/subfolder
if((isset($_GET['cat']) && is_string($_GET['cat']))) {
$currentCat = $_GET['cat'];
} else {
$currentCat = '';
}
$currentCat_id = 0;
$sRootDescription = NULL;
$bIsRootPage = false;
$all_cats = array();
$database->execute_query(
'SELECT * FROM `'.TABLE_PREFIX.'mod_foldergallery_categories` WHERE `section_id`='.$section_id.' AND `is_empty`=0 AND `active`=1 ORDER BY `position` DESC',
true,
$all_cats,
true
);
foreach($all_cats as &$result)
{
$p = $result['parent'].'/'.$result['categorie'] ;
if ($result['parent'] == '-1')
{
$p = '';
$sRootDescription = $result['description'];
$sRootTitle = $result['cat_name'];
}
if ($p == $currentCat)
{
$currentCat_id = $result['id'];
if( $result['parent'] == '-1' )
{
$bIsRootPage = true;
}
break;
}
}
// display root if there are no subfolders
if(!$currentCat){
$sql = 'SELECT * FROM '.TABLE_PREFIX.'mod_foldergallery_categories WHERE section_id='.$section_id.' AND parent="" AND is_empty=0 AND active=1 ORDER BY position ASC';
} else {
$sql = 'SELECT * FROM '.TABLE_PREFIX.'mod_foldergallery_categories WHERE section_id='.$section_id.' AND parent="'.$currentCat.'" AND is_empty=0 AND active=1 ORDER BY position DESC';
}
$subCats = array();
$database->execute_query(
$sql,
true,
$subCats,
true
);
if(count($subCats) == 0) {
$error = true;
}
if(count($subCats > 0) && $subCats['parent_id'] != -1) {
// get thumb (file_name) from files table
foreach($subCats as $thumb) {
if($catpic == 2) { // last
$cat_thumb = $database->get_one("SELECT file_name FROM ".TABLE_PREFIX."mod_foldergallery_files WHERE parent_id =".$thumb['parent_id']." ORDER BY position DESC");
}
if($catpic == 1) { // first
$cat_thumb = $database->get_one("SELECT file_name FROM ".TABLE_PREFIX."mod_foldergallery_files WHERE parent_id =".$thumb['parent_id']." ORDER BY position ASC");
}
if($catpic == 0) { // random
$all_thumbs = array();
$database->execute_query("SELECT file_name FROM ".TABLE_PREFIX."mod_foldergallery_files WHERE parent_id =".$thumb['parent_id']." ORDER BY position" ,
true,
$all_thumbs,
true
);
$cat_thumb = array_rand($all_thumbs);
}
}
}
echo(LEPTON_tools::display($cat_thumb,'pre','ui red message'));
echo('<br />');
echo(LEPTON_tools::display($subCats['categorie'],'pre','ui info message'));
$bread = "";
// create breadcrumb, get current cat path (only for subgalleries, not root)
if ( isset( $_GET['cat'] ) ) {
$path = explode( '/', $_GET['cat'] );
// first element is empty as the string begins with /
array_shift($path);
foreach ( $path as $i => $cat_name ) {
$catres = $database->query("SELECT cat_name FROM ".TABLE_PREFIX."mod_foldergallery_categories WHERE categorie = '$cat_name' LIMIT 1");
$cat = $catres->fetchRow();
$bread = '<li> <a href="'
. $oFGF->view_url
. '?cat=/'.implode('/', array_slice( $path, 0, ($i+1) ) )
. '">'.$cat['cat_name'].'</a></li>';
}
$breadcrumb = 1;
} else {
$breadcrumb = 0;
}
// get thumbsize from settings
$catWidth = $settings['thumb_size'] + 10;
if ($settings['ratio'] > 1) {
if ($settings['thumb_size'] >= 150) $catHeight = $settings['thumb_size'] + 10;
else $catHeight = $settings['thumb_size']/$settings['ratio'] + 50 ;
}
else {
if ($settings['thumb_size'] >= 150) $catHeight = $settings['thumb_size'] + 10;
else $catHeight = $settings['thumb_size'] + 50 ;
}
$data = array(
'oFGF' => $oFGF,
'page_id' => $page_id,
'section_id'=> $section_id,
'breadcrumb'=> $breadcrumb,
'bread' => $bread,
'subCats' =>$subCats,
'cat_thumb' =>$cat_thumb,
'page_title'=> PAGE_TITLE,
'all_cats'=>$all_cats,
'catWidth'=> $catWidth,
'catHeight'=> $catHeight,
// 'AllCartegories' => $aAllCartegories,
'leptoken' => get_leptoken()
);
echo $oTWIG->render(
"@foldergallery/frontend/view_".$settings['lightbox'].".lte", // template-filename
$data // template-data
);
?>