-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenreview.php
More file actions
369 lines (350 loc) · 17 KB
/
genreview.php
File metadata and controls
369 lines (350 loc) · 17 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
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
<?php
/*
* Property of Writale
* All rights reserved
* Writale © 2013
*/
if (!isset($_subject)) {
include realpath(dirname(__FILE__) . '/error/notfound.php');
exit();
}
require_once realpath(dirname(__FILE__) . "/control/session/saved.php");
require_once realpath(dirname(__FILE__) . "/control/general/cache.php");
try {
$_genre = new Genre(null, array(
'vanity' => $_subject
));
$_genre->setGenreId();
$_gn = $_genre->getGenreDetail();
if ($_gn['dp'] == null)
$_dplink = $_protocol . $_SERVER['HTTP_HOST'] . '/resource/image/misc/genre-150.jpg';
else
$_dplink = $_protocol . $_SERVER['HTTP_HOST'] . $_gn['md'] . '/' . $_gn['bnl'];
$_foll_status = $_genre->getFollowStatus();
$_self_link = $_protocol . $_SERVER['HTTP_HOST'] . '/' . $_subject;
$sec_name = '';
if (isset($_GET['tps'])) {
$_tops = 1;
$sec_name = '· Top Stories';
$_get_param = 'tops=1';
}
else if (isset($_GET['rn'])) {
$_running = 1;
$sec_name = '· Running Stories';
$_get_param = 'run=1';
}
else if (isset($_GET['cmp'])) {
$_complete = 1;
$sec_name = '· Closed Stories';
$_get_param = 'comp=1';
}
else
$_recent = 1;
$_gid = $_genre->getGenreId();
} catch (Exception $ex) {
Util::__errorSummary(WRITALE_ERR_GEN, $ex);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title><?php echo $_gn['genrename'].' '.$sec_name; ?></title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Writale is a simple, powerful way to read and build social stories." />
<link rel="shortcut icon" type="image/x-icon" href="//<?php echo $_SERVER['HTTP_HOST'] ?>/resource/image/icon/favicon.ico" />
<link rel="stylesheet" type="text/css" href="//<?php echo $_SERVER['HTTP_HOST'] . '/style/universal.css'; ?>" />
<link rel="stylesheet" type="text/css" href="//<?php echo $_SERVER['HTTP_HOST'] . '/style/strydlg.css'; ?>" />
<link rel="stylesheet" type="text/css" href="//<?php echo $_SERVER['HTTP_HOST']; ?>/style/gnr-0349-20022014.css" />
<script src="//<?php echo $_SERVER['HTTP_HOST'] ?>/script/common.js"></script>
<script src="//<?php echo $_SERVER['HTTP_HOST'] ?>/script/feedact.js"></script>
</head>
<body id="genre-body">
<input type="hidden" value="<?php echo $_gid; ?>" id="genreid" />
<?php if(isset($_get_param)): ?>
<input type="hidden" value="<?php echo $_get_param; ?>" id="get-param" />
<?php endif; ?>
<div id="feed-error" class="tiny-error"></div>
<div id="update-banner">This page has some updates which haven't been applied. Please refresh to see it.</div>
<?php
include realpath(dirname(__FILE__) . '/control/decorator/userpanel.php');
?>
<div id="general-outer-container">
<?php require realpath(dirname(__FILE__) . '/control/decorator/sidebar.php') ?>
<div id="general-middle-container">
<?php require realpath(dirname(__FILE__) . '/control/decorator/openstorypanel.php'); ?>
<div id="general-central-outline">
<div id="genre-data-container">
<div id="dp-container">
<div id="dp">
<img src="<?php echo $_dplink; ?>"
alt="" />
</div>
<div id="genre-utility">
<?php
if ($_foll_status) :
?>
<div class="button-std button-colorless inline" id="follow">
Unfollow
</div>
<?php
else :
?>
<div class="button-std button-gen inline" id="follow">
Follow
</div>
<?php
endif;
?>
<div class="button-std button-colorless inline" id="report-genre">
Report
</div>
</div>
</div>
<div id="genre-detail">
<div class="bold" id="genre-name">
<?php echo $_gn['genrename']; ?>
</div>
<div id="genre-desc">
<?php echo $_gn['description']; ?>
</div>
<div id="genre-legend">
<div class="inline g-legend">
<span id="fc"><?php echo Util::roundFigure($_gn['followcount']); ?> </span>
<div class="text">
<?php echo (1==$_gn['followcount']) ? 'Follower' : 'Followers'; ?>
</div>
</div>
<div class="inline g-legend">
<span><?php echo Util::roundFigure($_gn['openedcount']); ?></span>
<div class="text"> <?php
echo ($_gn['openedcount'] == 1) ? 'Story' : 'Stories';
?></div>
</div>
</div>
</div>
</div>
<div id="story-category-bar">
<div class="inline genre-top-link <?php if (isset($_recent)) echo 'bold'; ?>">
<a class="no-decorate" href="<?php echo $_self_link; ?>"
title="See all recent stories from <?php echo $_gn['genrename']; ?>.">Recent Stories</a>
</div>
<div class="inline genre-top-link <?php if (isset($_tops)) echo 'bold'; ?>">
<a class="no-decorate" href="<?php echo $_self_link . '?tps=1'; ?>"
title="See all top stories from <?php echo $_gn['genrename']; ?>.">Top Stories</a>
</div>
<div class="inline genre-top-link <?php if (isset($_running)) echo 'bold'; ?>">
<a class="no-decorate" href="<?php echo $_self_link . '?rn=1'; ?>"
title="See all incomplete stories from <?php echo $_gn['genrename']; ?>.">Running Stories</a>
</div>
<div class="inline genre-top-link <?php if (isset($_complete)) echo 'bold'; ?>">
<a class="no-decorate" href="<?php echo $_self_link . '?cmp=1'; ?>"
title="See completed stories from <?php echo $_gn['genrename']; ?>.">Closed Stories</a>
</div>
</div>
<div id="story-content">
<?php include realpath(dirname(__FILE__) . '/control/process/storyfetch.php'); ?>
<div id="page-loader" class="dnone">
<img src="<?php echo $_protocol . $_SERVER['HTTP_HOST'] . '/resource/image/misc/ajax-loader.gif'; ?>"
alt="" />
</div>
</div>
<?php require realpath(dirname(__FILE__) . '/control/decorator/pagefooter.php'); ?>
</div>
</div>
<div class="sidebar-right">
<div class="sidebar-upper-section">
<div class="button-std button-gen sidebar-up-button" id="add-gen">
Add
</div> a new genre.
<div class="divider"></div>
</div>
<div class="sidebar-lower-section">
<div id="text">
Other Genres
</div>
<div id="other-genres-content">
<?php
$og_res = $_mysql->query("SELECT genrename, genrevanity FROM genre"
. " WHERE genreid <> '$_gid' ORDER BY rand() LIMIT 9");
while($og_row = $og_res->fetch_assoc()) {
?>
<a class="oth-genre bold" href="<?php echo $_protocol.$_SERVER['HTTP_HOST'].
'/'.$og_row['genrevanity'];?>">
<?php echo $og_row['genrename']; ?>
</a>
<?php
}
?>
</div>
</div>
</div>
<span class="stretch"></span>
</div>
<?php
include realpath(dirname(__FILE__) . '/control/decorator/openstory.php');
include realpath(dirname(__FILE__) . '/control/decorator/utilbottom.php');
include realpath(dirname(__FILE__) . '/control/decorator/savedutil.php');
?>
<script src="//<?php echo $_SERVER['HTTP_HOST'] ?>/script/storysieve.js"></script>
<script>
var Genre = (function() {
var gid = _gAny('genreid').value,
nError = _gAny('feed-error'),
nFollow = _gAny('follow');
function processFollowing () {
var sParam = 'writalianfoljon?',
sText = this.innerHTML.trim ();
if (sText === 'Follow')
sParam += 'join_g=1&tg='+gid;
else if (sText === 'Unfollow')
sParam += 'unjoin_g=1&tg='+gid;
wxhr.writaleFj(sParam,nError,function (res) {
onFollow(sText,res);
});
util.dotLoader(this,1);
}
function onFollow (sText,res) {
util.dotLoader(nFollow,0);
var nFolCount = _gAny('fc'),
numFoll = Number(nFolCount.innerHTML.trim());
if(res == -1) {
nFollow.innerHTML = sText;
util.genError(nError, "Something's wrong! Please try later.");
}
else {
if(sText === 'Follow') {
nFollow.innerHTML = 'Unfollow';
nFollow.className = 'button-std button-colorless inline';
if(!isNaN(numFoll)) {
nFolCount.innerHTML = ((numFoll === 999) ? '1k' : numFoll+1);
if(numFoll === 0)
util.nextSibling(nFolCount).innerHTML = 'Follower';
}
}
else {
nFollow.innerHTML = 'Follow';
nFollow.className = 'button-std button-gen inline';
if(!isNaN(numFoll)) {
nFolCount.innerHTML = numFoll - 1;
if(numFoll === 2)
util.nextSibling(nFolCount).innerHTML = 'Follower';
}
}
}
}
// function bringPreview (e) {
// util.stopDefault(e);
// e.innerHTML = 'Fetching...';
// var sid = util.firstChild(this.parentNode.parentNode).value,
// param = '?qpx=1&qsid='+sid,
// self = this;
// wxhr.sendGenericRequest(param,function (res) {
// afterShowingPreview(res,self);
// });
// }
//
// function afterShowingPreview (res,node) {
// var sText;
// if(res == -1)
// util.genError(nError,
// "Something's wrong! Please try later.");
// else {
// sText = util.prevSibling(node);
// fade(sText,1);
// util.prevSibling(node).innerHTML = res;
// fade(node,0,40,function () {
// node.parentNode.removeChild(node);
// });
// }
// }
// var paginate = (function(iLims) {
// var
// oTar = _gAny('genre-content'),
// sLimTs = _gAny('feedts-1').value,
// nLoader = _gAny('page-loader');
//
// function init() {
// var iDocHeight = util.getDocumentHeight(),
// iScrollPos = $.documentElement.scrollTop || $.body.scrollTop,
// param = '?fg=' + gid + '&lim_ts=' + sLimTs + '&lim_a=' + iLims;
//<?php
//if (isset($_tops))
// print 'param += "&tops=1";';
//else if (isset($_running))
// print 'param += "&run=1";';
//else if (isset($_complete))
// print 'param += "&comp=1";';
?>//
// if (iScrollPos > (iDocHeight - 800)) {
// iLims += 3;
// removeEvent.call(window.self, 'scroll', paginate.init, false);
// fade(nLoader, 1, 40, false, true);
// wxhr.sendGenericRequest(param, afterPagination, '/process/genrefetch');
// }
// }
//
// function afterPagination(res) {
// var nError, nTemp;
// fade(nLoader, 0, 40, false, true);
// if (res == -1) {
// nError = $.createElement('div');
// nError.className = 'tiny-error visible';
// nError.id = "genre-page-error";
// nError.innerHTML = 'Hiccchhh! Something\'s wrong. Please try later.';
// oTar.appendChild(nError);
// }
// else if (res == -2) {
// nTemp = $.createElement('div');
// nTemp.className = 'no-feed-msg';
// nTemp.id = "no-more-story";
// nTemp.innerHTML = 'Sorry! No more stories to show right now.';
// oTar.insertBefore(nTemp, nLoader);
// }
// else {
// addEvent.call(window.self, 'scroll', paginate.init, false);
// nTemp = $.createElement('div');
// nTemp.innerHTML = res;
// while (nTemp.firstChild)
// oTar.insertBefore(nTemp.firstChild, nLoader);
// wfeed.core.init(1);
// addPreview ();
// }
// }
//
// return {
// init: init
// };
// })(3);
// function addPreview () {
// var node, nLink;
// while (node = _gAny('feedlet-' + iCount)) {
// if(nLink = _gAny('quick-' + iCount))
// addEvent.call(nLink, 'click', bringPreview, false);
// iCount++;
// }
// }
function init() {
wfeed.core.init(0);
if (_gAny('feedlet-1')) {
addEvent.call(window.self, 'scroll', storysieve.paginate.init, false);
}
storysieve.addPreview();
addEvent.call(nFollow,'click',processFollowing,false);
addEvent.call(_gAny('report-genre'), 'click', function () {
common.report ('gnr',gid);
},false);
addEvent.call(_gAny('add-gen'),'click', function () {
location.href = location.protocol+'//'+location.host+'/add';
},false);
}
return {
init: init
};
})();
(function() {
Genre.init();
})();
</script>
</body>
</html>