-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.php
153 lines (125 loc) · 4.27 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
<?php
header("Content-Type: text/html; charset=UTF-8");
require_once('includes/master.inc.php');
require_once('GlobalHandler.php');
require_once('NoteRouter.php');
GlobalHandler::executeGlobalRequests();
$edit = false;
$note = NoteRouter::fetchViewNote();
$author = null;
$showPrivacyNotice = false;
$showAuthor = false;
$privacyNote = '';
$hasError = false;
if ($note === false)
{
//Note does not exist
$note = (object)array();
$note->title = "Unknown Error";
$note->text = "There was an error loading this note.";
$note->nid = "Invalid";
$note->id = "";
$hasError = true;
}
else if (Auth::getAuth()->loggedIn() && $note->user_id == Auth::getAuth()->user->id)
{
//We are the author.
$showAuthor = true;
$showPrivacyNotice = true;
$privacyNote = "You are the author of this <b>public</b> note.";
if ($note->privacy != Note::PRIVACY_PUBLIC)
{
$privacyNote = "You are the author of this <b>private</b> note.";
}
}
else if ($note->privacy != Note::PRIVACY_PUBLIC)
{
//We are not the author, and it is private.
$hasError = true;
$note->title = "Note not Viewable.";
$note->text = "This note is no longer publicly viewable.";
$note->nid = "Invalid";
}
else
{
//We are not the author and the note is public
$showAuthor = true;
}
if ($showAuthor)
{
$author = new User();
if ($author->select($note->user_id) === false)
{
$author = null;
}
else if ($author->oauth_provider == "dailyoje")
{
$default = root_url() . '/images/user-avatar.png';
$author->image_url = "http://www.gravatar.com/avatar/" . md5(strtolower(trim($author->username))) . "?d=" . urlencode($default) . "&s=50";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $note->title; ?> - DailyOJE</title>
<link rel="stylesheet" type="text/css" href="<?php echo Config::get('googleFontUrl'); ?>">
<link rel="stylesheet" type="text/css" href="<?php echo root_url(); ?>css/style.css">
<link rel="stylesheet" type="text/css" href="<?php echo root_url(); ?>css/simplePagination.css">
<link rel="icon" type="image/png" href="<?php echo root_url(); ?>images/icon.png">
<script src="<?php echo Config::get('jQueryUrl'); ?>"></script>
<script src="<?php echo root_url(); ?>thirdjs/jquery.simplePagination.js"></script>
<script src="<?php echo Config::get('dailyOjeJsUrl'); ?>"></script>
<script type="text/javascript">
$(document).ready(function()
{
OJE.attachListeners();
OJE.rootUrl = "<?php echo root_url(); ?>";
OJE.view('viewText', 'viewTitle', '<?php echo $note->nid; ?>');
OJE.setupMenu();
<?php if(Auth::getAuth()->loggedIn()): ?>
OJE.loggedIn = true;
OJE.Note.fetchNotes(1, false);
<?php endif; ?>
<?php if($hasError): ?>
OJE.Note.toggleShareButton();
<?php endif; ?>
});
</script>
</head>
<body>
<?php include('templates/GoogleAnalytics.php'); ?>
<?php include('templates/Header.php'); ?>
<div id="wrapper">
<?php if ($showAuthor && isset($author)): ?>
<div id="authorInformation">
<?php if ($author->image_url): ?>
<img src="<?php echo $author->image_url; ?>" border="0"/>
<?php endif; ?>
<span id="authorName">
<a href="<?php echo $author->buildProfileUrl(); ?>" target="_blank">
<?php echo $author->name; ?>
</a>
</span>
<span class="grey-subtext" id="authorDescription"><?php echo $author->profile_details; ?></span>
</div>
<?php endif; ?>
<h1 id="viewTitle" class="editable-title"><?php echo $note->title; ?></h1>
<div class="editable " id="viewText">
<?php echo ($note->text); ?>
</div>
<div id="loadingNoteIndicator" class="loading-note-box" style="display: none">
<img src="<?php echo root_url(); ?>images/loading.horizontal.gif"/>
</div>
</div>
<?php if ($showPrivacyNotice): ?>
<div id="privateNotice">
<?php echo $privacyNote; ?>
<a href="<?php echo $note->editUrl(); ?>">Click
here to edit your note.</a>
</div>
<?php endif; ?>
<?php include("templates/Footer.php"); ?>
<?php include("templates/Sidebar.php"); ?>
</body>
</html>