-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpost_data.php
124 lines (115 loc) · 5.47 KB
/
post_data.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
<?php
/**
* MyWords for XOOPS
*
* Copyright © 2017 Eduardo Cortés http://www.eduardocortes.mx
* -------------------------------------------------------------
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
* -------------------------------------------------------------
* @copyright Eduardo Cortés (http://www.eduardocortes.mx)
* @license GNU GPL 2
* @package mywords
* @author Eduardo Cortés (AKA bitcero) <i.bitcero@gmail.com>
* @url http://www.eduardocortes.mx
*/
if (!defined('XOOPS_ROOT_PATH')) {
header('location: ./');
die();
}
// Authors cache
$editors = [];
while (false !== ($row = $db->fetchArray($result))) {
$post = new MWPost();
$post->assignVars($row);
# Generamos los vínculos
$day = date('d', $post->getVar('pubdate'));
$month = date('m', $post->getVar('pubdate'));
$year = date('Y', $post->getVar('pubdate'));
$link = $post->permalink();
# Generamos el vínculo para el autor
if ($post->getVar('author') > 0) {
if (!isset($editors[$post->getVar('author')])) {
$editors[$post->getVar('author')] = new MWEditor($post->getVar('author'), 'user');
}
if ($editors[$post->getVar('author')]->isNew()) {
if ($xoopsUser && $xoopsUser->uid() == $post->author) {
$user = $xoopsUser;
} else {
$user = new RMUser($post->author);
}
$editors[$post->getVar('author')]->uid = $user->uid();
$editors[$post->getVar('author')]->name = $user->getVar('name');
$editors[$post->getVar('author')]->shortname = $user->getVar('uname');
$editors[$post->getVar('author')]->privileges = [ 'tags', 'tracks', 'comms' ];
$editors[$post->getVar('author')]->save();
}
$editor = $editors[$post->getVar('author')];
$alink = $editor->permalink();
} else {
$alink = '';
}
# Información de Publicación
$published = sprintf(__('%s by %s', 'mywords'), MWFunctions::format_time($post->getVar('pubdate'), 'string'), '<a href="' . $alink . '">' . (isset($editor) ? $editor->name : __('Anonymous', 'mywords')) . '</a>');
# Texto de continuar leyendo
if ('password' === $post->getVar('visibility')) {
$text = isset($_SESSION['password-' . $post->id()]) && $_SESSION['password-' . $post->id()] == $post->getVar('password') ? $post->content(true) : MWFunctions::show_password($post);
} else {
$text = $post->content(true);
}
// Redes Sociales
if ($xoopsModuleConfig['showbookmarks']) {
$bms = [];
foreach ($socials as $bm) {
$bms[] = ['icon' => $bm->getVar('icon'), 'alt' => $bm->getVar('alt'), 'link' => str_replace(['{URL}', '{TITLE}', '{DESC}'], [$post->permalink(), $post->getVar('title'), TextCleaner::getInstance()->truncate($text, 50)], $bm->getVar('url'))];
}
}
$xoopsTpl->append('posts', [
'id' => $post->id(),
'title' => $post->getVar('title'),
'format' => $post->getVar('format'),
'text' => $text,
'description' => $post->getVar('description'),
'keywords' => $post->getVar('keywords'),
'cats' => $post->get_categos('data'),
'link' => $link,
'published' => $published,
'comments' => $post->getVar('comments'),
'lang_comments' => sprintf(__('%u Comments', 'mywords'), $post->getVar('comments')),
'continue' => $post->hasmore_text(),
'lang_continue' => $post->hasmore_text() ? sprintf(__('Read more about "%s"', 'mywords'), $post->getVar('title')) : '',
'bookmarks' => $bms,
'time' => $post->getVar('pubdate'),
'author' => [
'name' => '' != $editor->name ? $editor->name : $editor->shortname,
'id' => $editor->id(),
'link' => $editor->permalink(),
'bio' => $editor->getVar('bio'),
'email' => $editor->data('email'),
'avatar' => $cuServices->avatar->getAvatarSrc($editor->data('email'), 100),// RMEvents::get()->run_event( 'rmcommon.get.avatar', $editor->data('email') )
],
'alink' => $alink,
'edit' => $xoopsUser && ($xoopsUser->isAdmin() || $editor->getVar('uid') == $xoopsUser->uid()),
'tags' => $post->tags(false),
'meta' => $post->get_meta('', false),
'image' => $post->image(),
'video' => $post->video,
'player' => 'video' === $post->format ? $post->video_player() : '',
]);
}
$xoopsTpl->assign('lang_editpost', __('Edit Post', 'mywords'));
$xoopsTpl->assign('lang_postedin', __('Posted in:', 'mywords'));
$xoopsTpl->assign('lang_taggedas', __('Tagged as:', 'mywords'));
$xoopsTpl->assign('enable_images', $xoopsModuleConfig['list_post_imgs']);