1 | <?php /* |
---|
2 | Plugin Name: Admin Advices ! |
---|
3 | Version: 1.0.0 |
---|
4 | Author: PhpWebGallery team |
---|
5 | Description: Give you an advice on the administration page. |
---|
6 | */ |
---|
7 | |
---|
8 | add_event_handler('loc_begin_page_tail', 'set_admin_advice' ); |
---|
9 | |
---|
10 | |
---|
11 | function set_admin_advice() |
---|
12 | { |
---|
13 | global $page, $user, $template, $conf; |
---|
14 | |
---|
15 | // This Plugin works only on the Admin page |
---|
16 | if ( isset($page['body_id']) and $page['body_id']=='theAdminPage' |
---|
17 | and $page['page'] == 'intro' |
---|
18 | ) |
---|
19 | { |
---|
20 | // Setup Advice Language (Maybe there is already a variable) |
---|
21 | $advlang = ( isset($user['language']) ) ? |
---|
22 | $user['language'] : $conf['default_language']; // en_UK.iso-8859-1 |
---|
23 | |
---|
24 | $adv = array(); |
---|
25 | |
---|
26 | // Include language advices |
---|
27 | include_once( PHPWG_ROOT_PATH |
---|
28 | . "plugins/admin_advices/$advlang/lang.adv.php" ); |
---|
29 | |
---|
30 | // If there is an advice |
---|
31 | if ( $cond ) |
---|
32 | { |
---|
33 | // $template->set_filenames( array( 'advice' => 'admin_advices.tpl' )); |
---|
34 | $template->set_filenames(array( |
---|
35 | 'admin_advice' => |
---|
36 | PHPWG_ROOT_PATH.'/plugins/admin_advices/admin_advices.tpl') |
---|
37 | ); |
---|
38 | |
---|
39 | // Random Thumbnail |
---|
40 | $query = ' |
---|
41 | SELECT * |
---|
42 | FROM '.IMAGES_TABLE.' |
---|
43 | ORDER BY RAND(NOW()) |
---|
44 | LIMIT 0, 1 |
---|
45 | ;'; |
---|
46 | $result = pwg_query($query); |
---|
47 | $row = mysql_fetch_assoc($result); |
---|
48 | if ( is_array($row) ) |
---|
49 | { |
---|
50 | $template->assign_block_vars( |
---|
51 | 'thumbnail', |
---|
52 | array( |
---|
53 | 'IMAGE' => get_thumbnail_url($row), |
---|
54 | 'IMAGE_ALT' => $row['file'], |
---|
55 | 'IMAGE_TITLE' => $row['name'], |
---|
56 | ) |
---|
57 | ); |
---|
58 | } |
---|
59 | $advice_text = array_shift($adv); |
---|
60 | $template->assign_vars( |
---|
61 | array( |
---|
62 | 'ADVICE_ABOUT' => '$conf[' . "'$confk'] ", |
---|
63 | 'ADVICE_TEXT' => $advice_text, |
---|
64 | ) |
---|
65 | ); |
---|
66 | foreach ($adv as $advice) |
---|
67 | { |
---|
68 | $template->assign_block_vars( |
---|
69 | 'More', |
---|
70 | array( |
---|
71 | 'ADVICE' => $advice |
---|
72 | ) |
---|
73 | ); |
---|
74 | } |
---|
75 | $template->parse('admin_advice'); |
---|
76 | } |
---|
77 | } |
---|
78 | } |
---|
79 | ?> |
---|