My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
<?php

/**
* OverviewItems Class, Furasta.Org
*
* Manages overview items.
*
* @author Conor Mac Aoidh <conormacaoidh@gmail.com>
* @license http://furasta.org/licence.txt The BSD License
* @version 1.0
* @package admin_overview
*/

/**
* OverviewItems
*
* This class manages the overview items.
*
* @package admin_overview
* @version 1.0
* @author Conor Mac Aoidh <conormacaoidh@gmail.com>
* @license http://furasta.org/licence.txt The BSD License
*/
class OverviewItems{

/**
* items
*
* Stores an array of overview items.
*
* @var array
* @access private
*/
private $items = array( );

/**
* order
*
* Stored the cached order of overview items.
*
* @var array
* @access private
*/
private $order = array( );

/**
* status
*
* Stores the cached status of overview
* items, ie open or closed.
*
* @var array
* @access private
*/
private $status = array( );

/**
* __construct
*
* Loads plugin overview items into the
* $items array.
*
* @access protected
* @return void
*/
function __construct( ){

$Template = Template::getInstance( );

/**
* enable default overview items
*/
$items = array(
array(
'name' => $Template->e( 'overview_website_overview' ),
'id' => 'website-overview',
'status'=> 'open'
),
array(
'name' => $Template->e( 'overview_recently_edited' ),
'id' => 'recently-edited',
'status'=> 'open'
),
array(
'name' => $Template->e( 'overview_recently_trashed' ),
'id' => 'recently-trashed',
'status'=> 'open'
),
array(
'name' => $Template->e( 'overview_furasta_development_blog' ),
'id' => 'furasta-devblog',
'status'=> 'open'
)
);

/**
* add plugin overview items
*/
$Plugins = Plugins::getInstance( );
$items = array_merge( $Plugins->adminOverviewItems( ) , $items );

/**
* make sure user has permission to view trash item
*/
$User = User::getInstance( );
if( !$User->hasPerm( 't' ) )
unset( $items[ 3 ] );

$this->items = $items;

}

/**
* order
*
* Re-orders the $items array according to
* a cached order file.
*
* @access public
* @return bool
*/
function order( ){
$items = $this->items;

$cache_file = 'FURASTA_OVERVIEW_ITEMS_STATUS_' . $_SESSION[ 'user' ][ 'id' ];

if( cache_exists( $cache_file, 'USERS' ) ){
$items_status = json_decode( cache_get( $cache_file, 'USERS' ) );

foreach( $items as $item => $value ){
foreach( $items_status as $key => $status ){
if( $value[ 'id' ] == $key ){
$items[ $item ][ 'status' ] = $status;
break;
}
}
}
}

$cache_file = 'FURASTA_OVERVIEW_ITEMS_' . $_SESSION[ 'user' ][ 'id' ];

if( cache_exists( $cache_file, 'USERS' ) )
$order = json_decode( cache_get( $cache_file, 'USERS' ), true );
else{
$order = array(
'1' => array( 'website-overview', 'recently-trashed' ),
'2' => array( 'recently-edited', 'furasta-devblog' )
);
cache( $cache_file, json_encode( $order ), 'USERS' );
}

$ordered = array( );
$num = 0;

foreach( $order as $key => $value ){
foreach( $value as $id ){
$num++;
foreach( $items as $item => $vals ){
if( $vals[ 'id' ] == $id ){
$ordered[ $key ][ $num ] = $vals;
unset( $items[ $item ] );
break;
}
}
}
}

if( count( $items ) != 0 ){
for( $i=0; $i<= ( count( $items ) -1 ); $i++ ){
$num++;
if( $i%2 )
$ordered[ '2' ][ $num ]= $items[ $i ];
else
$ordered[ '1' ][ $num ] = $items[ $i ];
}
}

return ( $this->items = $ordered );
}

/**
* displayItems
*
* Returns a formatted version of the
* $items array.
*
* @access public
* @return string
*/
function displayItems( ){
$items = $this->items;
$content = '<div class="sort-container column_one" style="float:left">';

foreach( $items[ '1' ] as $item ){
$status = ( $item[ 'status' ] == 'open' ) ? '-' : '+';
$content .= '<div class="overview-preview" id="' . $item[ 'id' ] . '">
<p class="th"><a class="collapse-button" class="right">' . $status . '</a><span>' . $item[ 'name' ] . '</span></p>'
.'<div class="collapse-content '. $item[ 'status' ] . '"></div></div>';
}

$content .= '</div><div class="sort-container column_two" style="margin-left:50%">';

foreach( $items[ '2' ] as $item ){
$status = ( $item[ 'status' ] == 'open' ) ? '-' : '+';
$content .= '<div class="overview-preview" id="' . $item[ 'id' ] . '">
<p class="th"><a class="collapse-button" class="right">' . $status . '</a><span>' . $item[ 'name' ] .'</span></p>'
.'<div class="collapse-content ' . $item[ 'status' ] . '"></div></div>';
}

$content .= '</div>';

return $content;
}
}

?>

Change log

r38 by conormacaoidh on Dec 24, 2011   Diff
more progress on the irish language
translation. also changed how the language
files work a bit
Go to: 
Project members, sign in to write a code review

Older revisions

r17 by conormacaoidh on Jan 6, 2011   Diff
change to caching system, page_tree,
css_load and javascript_load template
functions added
r14 by conormacaoidh on Jan 2, 2011   Diff
added meta tag generator, fixed
settings configuration page and a few
other small things
r12 by conormacaoidh on Dec 24, 2010   Diff
redesigned User class, groups changes
to come
All revisions of this file

File info

Size: 5759 bytes, 216 lines
Powered by Google Project Hosting