/
view.php
177 lines (151 loc) · 5.8 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
<?php
/**
* This View is responsible for generating layout parts
* @package News Show Pro GK5
* @Copyright (C) 2009-2014 Gavick.com
* @ All rights reserved
* @ Joomla! is Free Software
* @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* @version $Revision: GK5 1.6.2 $
**/
// access restriction
defined('_JEXEC') or die('Restricted access');
class NSP_GK5_View {
// header generator
static function header($config, $item) {
if($config['news_content_header_pos'] != 'disabled') {
$class = ' t'.$config['news_content_header_pos'].' f'.$config['news_content_header_float'];
if(static::image($config, $item, true, true) != '') {
$class .= ' has-image';
}
$output = NSP_GK5_Utils::cutText(htmlspecialchars($item['title']), $config, 'title_limit', '…');
$output = str_replace('"', """, $output);
// first word span wrap
if($config['news_header_first_word'] == 1) {
$output_temp = explode(' ', $output);
$first_word = $output_temp[0];
$output_temp[0] = '<span>'.$output_temp[0].'</span>';
$output = preg_replace('/' . $first_word . '/mi', $output_temp[0], $output, 1);
}
$link = static::itemLink($item, $config);
//
if($config['news_header_link'] == 1) {
return '<h4 class="nspHeader'.$class.'"><a href="'.$link.'" title="'.htmlspecialchars($item['title']).'" target="'.$config['open_links_window'].'">'.$output.'</a></h4>';
} else {
return '<h4 class="nspHeader'.$class.'" title="'.htmlspecialchars($item['title']).'">'.$output.'</h4>';
}
} else {
return '';
}
}
// article text generator
static function text($config, $item, $readmore) {
if($config['news_content_text_pos'] != 'disabled') {
//
$item['text'] = NSP_GK5_Utils::cutText($item['text'], $config, 'news_limit');
$item['text'] = static::textPlugins($item['text'], $config);
$link = static::itemLink($item, $config);
//
$item['text'] = ($config['news_text_link'] == 1) ? '<a href="'.$link.'" target="'.$config['open_links_window'].'">'.$item['text'].'</a>' : $item['text'];
$class = ' t'.$config['news_content_text_pos'].' f'.$config['news_content_text_float'];
//
if($config['news_content_readmore_pos'] == 'after') {
return '<p class="nspText'.$class.'">'.$item['text'].' '.$readmore.'</p>';
} else {
return '<p class="nspText'.$class.'">'.$item['text'].'</p>';
}
} else {
return '';
}
}
// ReadMore button generator
static function readMore($config, $item) {
//
if($config['news_content_readmore_pos'] != 'disabled') {
$class = ' f'.$config['news_content_readmore_pos'];
$link = static::itemLink($item, $config);
//
if($config['news_content_readmore_pos'] == 'after') {
return '<a class="readon inline" href="'.$link.'" target="'.$config['open_links_window'].'">'.((trim($config['readmore_text']) != '') ? $config['readmore_text'] : JText::_('MOD_NEWS_PRO_GK5_NSP_READMORE')).'</a>';
} else {
return '<a class="readon '.$class.'" href="'.$link.'" target="'.$config['open_links_window'].'">'.((trim($config['readmore_text']) != '') ? $config['readmore_text'] : JText::_('MOD_NEWS_PRO_GK5_NSP_READMORE')).'</a>';
}
} else {
return '';
}
}
// rest link list generator
static function lists($config, $item, $num) {
$odd = $num % 2;
if($config['news_short_pages'] > 0) {
$text = '';
$title = '';
$image = '';
$readmore = '';
$link = static::itemLink($item, $config);
if($config['list_text_limit'] > 0) {
$item['text'] = static::textPlugins($item['text'], $config);
$text = NSP_GK5_Utils::cutText(strip_tags($item['text']), $config, 'list_text_limit', '…');
if(JString::strlen($text) > 0) {
$text = '<p>'.$text.'</p>';
}
}
if($config['list_title_limit'] > 0) {
$title = htmlspecialchars($item['title']);
$title = NSP_GK5_Utils::cutText($title, $config, 'list_title_limit', '…');
$title = str_replace('"', """, $title);
if(JString::strlen($title) > 0) {
$title = '<h4><a href="'.$link.'" title="'.htmlspecialchars($item['title']).'" target="'.$config['open_links_window'].'">'.$title.'</a></h4>';
}
}
if($config['links_image'] == 1) {
$image = static::image($config, $item, false, false, true);
}
if($config['links_readmore'] == 1) {
$readmore = '<a class="readon" href="'.$link.'" target="'.$config['open_links_window'].'">'.((trim($config['readmore_text']) != '') ? $config['readmore_text'] : JText::_('MOD_NEWS_PRO_GK5_NSP_READMORE')).'</a>';
}
// creating rest news list
return '<li class="'.(($odd == 1) ? 'odd' : 'even').'">' . $image . (($image != '') ? '<div>' . $title . $text . $readmore . '</div>' : ($title . $text . $readmore)) . '</li>';
} else {
return '';
}
}
// article image generator
static function image($config, $item, $only_url = false, $pm = false, $links = false){
return '';
}
// article information generator
static function info($config, $item, $num = 1) {
return '';
}
// article link generator
static function itemLink($item, $config = false) {
return '';
}
// category link generator
static function categoryLink($item) {
return '';
}
// user link generator
static function authorLink($item) {
return '';
}
// article image generator
static function originalImage($config, $item){
return '';
}
// Plugin text cleaner
static function textPlugins($text, $config) {
// PARSING PLUGINS
if($config['parse_plugins'] == TRUE) {
$text = JHtml::_('content.prepare', $text);
}
// CLEANING PLUGINS
if($config['clean_plugins'] == TRUE) {
$text = preg_replace("/(\{.+?\}.+?\{.+?})|(\{.+?\})/", "", $text);
$text = preg_replace("/(\[.+?\].+?\[.+?])|(\[.+?\])/", "", $text);
}
return $text;
}
}
// EOF