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 | // | PhpWebGallery - a PHP based picture gallery | |
---|
9 | // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | |
---|
10 | // +-----------------------------------------------------------------------+ |
---|
11 | // | branch : BSF (Best So Far) |
---|
12 | // | file : $URL$ |
---|
13 | // | last update : $Date$ |
---|
14 | // | last modifier : $Author$ |
---|
15 | // | revision : $Rev$ |
---|
16 | // +-----------------------------------------------------------------------+ |
---|
17 | // | This program is free software; you can redistribute it and/or modify | |
---|
18 | // | it under the terms of the GNU General Public License as published by | |
---|
19 | // | the Free Software Foundation | |
---|
20 | // | | |
---|
21 | // | This program is distributed in the hope that it will be useful, but | |
---|
22 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
23 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
24 | // | General Public License for more details. | |
---|
25 | // | | |
---|
26 | // | You should have received a copy of the GNU General Public License | |
---|
27 | // | along with this program; if not, write to the Free Software | |
---|
28 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
29 | // | USA. | |
---|
30 | // +-----------------------------------------------------------------------+ |
---|
31 | |
---|
32 | add_event_handler('loc_end_page_header', 'set_admin_advice_add_css' ); |
---|
33 | |
---|
34 | // Add a XHTML tag in HEAD section |
---|
35 | function set_admin_advice_add_css() |
---|
36 | { |
---|
37 | global $template, $page; |
---|
38 | if ( isset($page['body_id']) and $page['body_id']=='theAdminPage' |
---|
39 | and $page['page'] == 'intro' |
---|
40 | ) |
---|
41 | {// This Plugin works only on the Admin page |
---|
42 | $template->assign_block_vars( |
---|
43 | 'head_element', |
---|
44 | array( |
---|
45 | 'CONTENT' => '<link rel="stylesheet" type="text/css" ' |
---|
46 | . 'href="'.PHPWG_PLUGINS_PATH.'admin_advices/default-layout.css" />', |
---|
47 | ) |
---|
48 | ); |
---|
49 | add_event_handler('loc_begin_page_tail', 'set_admin_advice' ); |
---|
50 | } |
---|
51 | } |
---|
52 | |
---|
53 | // Build an advice on the Admin Intro page |
---|
54 | function set_admin_advice() |
---|
55 | { |
---|
56 | global $page, $user, $template, $conf; |
---|
57 | |
---|
58 | // Setup Advice Language (Maybe there is already a variable) |
---|
59 | $advlang = ( isset($user['language']) ) ? |
---|
60 | $user['language'] : $conf['default_language']; // en_UK.iso-8859-1 |
---|
61 | $my_path = dirname(__FILE__).'/'; |
---|
62 | $adv = array(); |
---|
63 | if ( !@file_exists($my_path."$advlang/lang.adv.php") ) |
---|
64 | { |
---|
65 | $advlang = 'en_UK.iso-8859-1'; |
---|
66 | } |
---|
67 | // Include language advices |
---|
68 | @include_once( $my_path."$advlang/lang.adv.php" ); |
---|
69 | |
---|
70 | // If there is an advice |
---|
71 | if ( $cond ) |
---|
72 | { |
---|
73 | $template->set_filenames(array( |
---|
74 | 'admin_advice' => $my_path.'admin_advices.tpl') |
---|
75 | ); |
---|
76 | |
---|
77 | // Random Thumbnail |
---|
78 | $query = ' |
---|
79 | SELECT * |
---|
80 | FROM '.IMAGES_TABLE.' |
---|
81 | ORDER BY RAND(NOW()) |
---|
82 | LIMIT 0, 1 |
---|
83 | ;'; |
---|
84 | $result = pwg_query($query); |
---|
85 | $row = mysql_fetch_assoc($result); |
---|
86 | if ( is_array($row) ) |
---|
87 | { |
---|
88 | $url_modify = get_root_url().'admin.php?page=picture_modify' |
---|
89 | .'&image_id='.$row['id']; |
---|
90 | $url_check = get_themeconf('icon_dir').'/'; |
---|
91 | $url_uncheck = $url_check . 'uncheck'; |
---|
92 | $url_check .= 'check'; |
---|
93 | $picture_id = $row['id']; |
---|
94 | $query = ' |
---|
95 | SELECT * FROM '.IMAGE_TAG_TABLE.' |
---|
96 | WHERE image_id = ' . $picture_id .' |
---|
97 | ;'; |
---|
98 | $tag_count = mysql_num_rows(mysql_query($query)); |
---|
99 | $template->assign_block_vars( |
---|
100 | 'thumbnail', |
---|
101 | array( |
---|
102 | 'IMAGE' => get_thumbnail_url($row), |
---|
103 | 'IMAGE_ALT' => $row['file'], |
---|
104 | 'IMAGE_TITLE' => $row['name'], |
---|
105 | 'METADATA' => (empty($row['date_metadata_update'])) ? |
---|
106 | $url_uncheck : $url_check, |
---|
107 | 'NAME' => (empty($row['name'])) ? |
---|
108 | $url_uncheck : $url_check, |
---|
109 | 'COMMENT' => (empty($row['comment'])) ? |
---|
110 | $url_uncheck : $url_check, |
---|
111 | 'AUTHOR' => (empty($row['author'])) ? |
---|
112 | $url_uncheck : $url_check, |
---|
113 | 'CREATE_DATE' => (empty($row['date_creation'])) ? |
---|
114 | $url_uncheck : $url_check, |
---|
115 | 'TAGS' => ($tag_count == 0) ? |
---|
116 | $url_uncheck : $url_check, |
---|
117 | 'NUM_TAGS' => (string) $tag_count, |
---|
118 | 'U_MODIFY' => $url_modify, |
---|
119 | ) |
---|
120 | ); |
---|
121 | } |
---|
122 | $advice_text = array_shift($adv); |
---|
123 | $template->assign_vars( |
---|
124 | array( |
---|
125 | 'ADVICE_ABOUT' => '$conf[' . "'$confk'] ", |
---|
126 | 'ADVICE_TEXT' => $advice_text, |
---|
127 | ) |
---|
128 | ); |
---|
129 | foreach ($adv as $advice) |
---|
130 | { |
---|
131 | $template->assign_block_vars( |
---|
132 | 'More', |
---|
133 | array( |
---|
134 | 'ADVICE' => $advice |
---|
135 | ) |
---|
136 | ); |
---|
137 | } |
---|
138 | $template->parse('admin_advice'); |
---|
139 | } |
---|
140 | } |
---|
141 | ?> |
---|