-
Notifications
You must be signed in to change notification settings - Fork 0
/
xef.php
executable file
·180 lines (153 loc) · 4.99 KB
/
xef.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
<?php
/**
* XEF - ThemeXpert Extension Framework
*
* An extension development framework for ThemeXpert
*
* @package XEF - ThemeXpert Extension Framework
* @author ThemeXpert Team
* @copyright Copyright (c) 2010 - 2012, ThemeXpert.
* @license GNU General Public License version 3, or later
* @link http://www.themexpert.com
* @since 1.0
*
*/
// Protect from unauthorized access
defined('_JEXEC') or die('Restricted access');
/**
* ThemeXpert Extension Framework (XEF) helper class
*
* ThemeXpert Extension Framework (XEF) is a set of classes which extends Joomla! 2.5 and later's
* MVC framework with features making maintaining all ThemeXpert's extensions much easier.
*
* Initially designed for module development and more coming...
*/
class XEFHelper
{
public $params; // Hold the extension params. we'll not allow to access it from outside.
public $module; // Module object hold the module information
/*
* Constructor
* @params object $params get the module params object
*
* @return NULL
*
**/
public function __construct( $module, $params )
{
$this->module = $module;
$this->params = $params;
}
/*
* Get the value of given param or set to default
*
* @params string $param name of the field
*
* @default string $default set default value if no value found on param
*
* @return string/int $value Value return for given field
*
**/
public function get( $param , $default=NULL )
{
$value = ( $this->params->get($param) != NULL ) ? $this->params->get($param) : $default;
return $value;
}
/*
* Set the value to given param
*
* @params string $field name of the field
*
* @value string/int $value set value to the field
*
**/
public function set( $field, $value )
{
$this->params->set( $field, $value );
}
/*
* Get Itemid from module settings.
* @params ''
* @return string $itemId;
*/
public function getMenuItemId()
{
$itemId = '';
$routing_type = $this->get( 'routing_type', 'default' );
if( $routing_type != 'default' )
{
switch ($routing_type) {
case 'menuitem':
$itemId = $this->get( 'menuitemid' ) ? '&Itemid=' . $this->get( 'menuitemid' ) : '';
break;
default:
break;
}
}
return $itemId;
}
/*
* Prepare items before going to view.
*
* @params object $items Items object
*
* @return Object $items modified items object
*
**/
public function prepareItems($items)
{
//$source = $this->get('content_source');
foreach ($items as $item)
{
// Clean title
$item->title = JFilterOutput::ampReplace($item->title);
// Category name & link
$item->catname = $this->getCategory($item);
$item->catlink = $this->getCategoryLink($item);
// Link
$item->link = $this->getLink($item);
// Image
$item->image = $this->getImage($item);
// Date
$item->date = $this->getDate($item);
// Set image dimension
$dimensions = array(
'width' => $this->get('image_width',400),
'height' => $this->get('image_height',300)
);
// If thumbnail is enable set its property
if( $this->get('navigation') == 'thumb' OR
$this->get('thumb') )
{
$thumb_dimensions = array(
'width' => $this->get('thumb_width',100),
'height' => $this->get('thumb_height',100)
);
$item->thumb = XEFUtility::getResizedImage($item->image, $thumb_dimensions, $this->module, '_thumb');
}
// Finally re-sized image if image re-sizer is on
if($this->get('image_resize'))
{
$item->image = XEFUtility::getResizedImage($item->image, $dimensions, $this->module);
}
// Intro text
$filter_by = $this->get('intro_limit_type');
// Trim intro text based on filter type
if( $filter_by == 'words' )
{
$item->introtext = XEFUtility::wordLimit($item->introtext, $this->get('intro_limit',100) );
}elseif($filter_by == 'chars')
{
$item->introtext = XEFUtility::characterLimit($item->introtext, $this->get('intro_limit',100) );
}
// else{
// $item->introtext = $item->intro;
// }
if($this->get('prepare_content', false))
{
$item->introtext = JHtml::_('content.prepare', $item->introtext, '', 'com_content.article');
}
}
return $items;
}
}