forked from zenphoto/zenphoto
/
functions.php
214 lines (202 loc) · 6.22 KB
/
functions.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
<?php
// force UTF-8 Ø
require_once (SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/image_album_statistics.php');
zp_register_filter('themeSwitcher_head', 'switcher_head');
zp_register_filter('themeSwitcher_Controllink', 'switcher_controllink');
zp_register_filter('load_theme_script', 'fourOhFour');
$cwd = getcwd();
chdir(dirname(__FILE__));
$persona = safe_glob('*', GLOB_ONLYDIR);
chdir($cwd);
$persona = array_diff($persona, array('images', 'contact_form'));
$personalities = array();
foreach ($persona as $personality) {
$personalities[ucfirst(str_replace('_', ' ', $personality))] = $personality;
}
if (!OFFSET_PATH) {
if (extensionEnabled('themeSwitcher')) {
$personality = getOption('themeSwitcher_garland_personality');
if (isset($_GET['themePersonality'])) {
$new = $_GET['themePersonality'];
if (in_array($new, $personalities)) {
setOption('themeSwitcher_garland_personality', $new);
$personality = $new;
}
}
if ($personality) {
setOption('garland_personality', $personality, false);
} else {
$personality = strtolower(getOption('garland_personality'));
}
} else {
$personality = strtolower(getOption('garland_personality'));
}
if (!in_array($personality, $personalities)) {
$persona = $personalities;
$personality = array_shift($persona);
}
require_once(SERVERPATH . '/' . THEMEFOLDER . '/garland/' . $personality . '/functions.php');
$_oneImagePage = $handler->onePage();
$_zp_page_check = 'my_checkPageValidity';
}
function switcher_head($ignore) {
?>
<script type="text/javascript">
// <!-- <![CDATA[
function switchPersonality() {
personality = $('#themePersonality').val();
window.location = '?themePersonality=' + personality;
}
// ]]> -->
</script>
<?php
return $ignore;
}
function switcher_controllink($html) {
global $personalities, $_zp_gallery_page;
$personality = getOption('themeSwitcher_garland_personality');
if (!$personality) {
$personality = getOption('garland_personality');
}
?>
<span id="themeSwitcher_garland">
<span title="<?php echo gettext("Garland image display handling."); ?>">
<?php echo gettext('Personality'); ?>
<select name="themePersonality" id="themePersonality" onchange="switchPersonality();">
<?php generateListFromArray(array($personality), $personalities, false, true); ?>
</select>
</span>
</span>
<?php
return $html;
}
function gMapOptionsImage($map) {
}
function gMapOptionsAlbum($map) {
global $points;
foreach ($points as $coord) {
addGeoCoord($map, $coord);
}
}
function footer() {
global $_zp_gallery_page, $_zp_current_category, $_zp_gallery;
?>
<div id="footer">
<?php
if (function_exists('printFavoritesURL') && $_zp_gallery_page != 'password.php' && $_zp_gallery_page != 'favorites.php') {
printFavoritesURL(NULL, '', ' | ', '<br />');
}
if (class_exists('RSS')) {
$prev = ' | ';
switch ($_zp_gallery_page) {
default:
printRSSLink('Gallery', '', 'RSS', '');
break;
case 'album.php':
printRSSLink('Album', '', 'RSS', '');
break;
case 'news.php':
if (is_NewsCategory()) {
printRSSLink('Category', '', 'RSS', '', true, null, '', NULL, $_zp_current_category->getTitlelink());
} else {
printRSSLink('News', '', 'RSS', '');
}
break;
case 'password.php':
$prev = '';
break;
}
} else {
$prev = '';
}
if ($_zp_gallery_page != 'password.php' && $_zp_gallery_page != 'archive.php') {
printCustomPageURL(gettext('Archive View'), 'archive', '', $prev, '');
$prev = ' | ';
}
?>
<?php
if ($_zp_gallery_page != 'contact.php' && extensionEnabled('contact_form') && ($_zp_gallery_page != 'password.php' || $_zp_gallery->isUnprotectedPage('contact'))) {
printCustomPageURL(gettext('Contact us'), 'contact', '', $prev, '');
$prev = ' | ';
}
?>
<?php
if ($_zp_gallery_page != 'register.php' && function_exists('printRegisterURL') && !zp_loggedin() && ($_zp_gallery_page != 'password.php' || $_zp_gallery->isUnprotectedPage('register'))) {
printRegisterURL(gettext('Register for this site'), $prev, '');
$prev = ' | ';
}
?>
<?php @call_user_func('printUserLogin_out', $prev); ?>
<br />
<?php @call_user_func('mobileTheme::controlLink'); ?>
<br />
<?php @call_user_func('printLanguageSelector'); ?>
<?php printZenphotoLink(); ?>
</div>
<?php
}
function commonNewsLoop($paged) {
$newstypes = array('album' => gettext('album'), 'image' => gettext('image'), 'video' => gettext('video'), 'news' => gettext('news'));
while (next_news()) {
$newstypedisplay = gettext('news');
if (stickyNews()) {
$newstypedisplay .= ' <small><em>' . gettext('sticky') . '</em></small>';
}
?>
<div class="newsarticle<?php if (stickyNews()) echo ' sticky'; ?>">
<h3><?php printNewsURL(); ?><?php echo " <span class='newstype'>[" . $newstypedisplay . "]</span>"; ?></h3>
<div class="newsarticlecredit">
<span class="newsarticlecredit-left">
<?php
$count = @call_user_func('getCommentCount');
$cat = getNewsCategories();
printNewsDate();
if ($count > 0) {
echo ' | ';
printf(gettext("Comments: %d"), $count);
}
?>
</span>
<?php
if (!empty($cat) && !in_context(ZP_ZENPAGE_NEWS_CATEGORY)) {
echo ' | ';
printNewsCategories(", ", gettext("Categories: "), "newscategories");
}
?>
</div> <!-- newsarticlecredit -->
<br class="clearall" />
<?php printCodeblock(1); ?>
<?php printNewsContent(); ?>
<?php printCodeblock(2); ?>
<br class="clearall" />
</div>
<?php
}
if ($paged) {
printNewsPageListWithNav(gettext('next »'), gettext('« prev'), true, 'pagelist', true);
}
}
function exerpt($content, $length) {
return shortenContent(getBare($content), $length, getOption("zenpage_textshorten_indicator"));
}
function my_checkPageValidity($request, $gallery_page, $page) {
switch ($gallery_page) {
case 'gallery.php':
$gallery_page = 'index.php'; // same as an album gallery index
break;
case 'index.php':
if (!extensionEnabled('zenpage')) { // only one index page if zenpage plugin is enabled or there is a custom index page
break;
}
default:
if ($page != 1) {
return false;
}
case 'news.php':
case 'album.php':
case 'search.php':
break;
}
return checkPageValidity($request, $gallery_page, $page);
}
?>