1 | <?php /* |
---|
2 | Plugin Name: Admin Advices |
---|
3 | Version: 1.0 |
---|
4 | Description: Give you an advice on the administration page. |
---|
5 | Plugin URI: http://www.phpwebgallery.net |
---|
6 | Author: PhpWebGallery team |
---|
7 | Author URI: http://www.phpwebgallery.net |
---|
8 | */ |
---|
9 | |
---|
10 | add_event_handler('loc_end_page_header', 'set_admin_advice_add_css' ); |
---|
11 | |
---|
12 | // Add a XHTML tag in HEAD section |
---|
13 | function set_admin_advice_add_css() |
---|
14 | { |
---|
15 | global $template, $page; |
---|
16 | if ( isset($page['body_id']) and $page['body_id']=='theAdminPage' |
---|
17 | and $page['page'] == 'intro' |
---|
18 | ) |
---|
19 | {// This Plugin works only on the Admin page |
---|
20 | $template->assign_block_vars( |
---|
21 | 'head_element', |
---|
22 | array( |
---|
23 | 'CONTENT' => '<link rel="stylesheet" type="text/css" ' |
---|
24 | . 'href="'.PHPWG_PLUGINS_PATH.'admin_advices/default-layout.css">', |
---|
25 | ) |
---|
26 | ); |
---|
27 | add_event_handler('loc_begin_page_tail', 'set_admin_advice' ); |
---|
28 | } |
---|
29 | } |
---|
30 | |
---|
31 | // Build an advice on the Admin Intro page |
---|
32 | function set_admin_advice() |
---|
33 | { |
---|
34 | global $page, $user, $template, $conf; |
---|
35 | |
---|
36 | // Setup Advice Language (Maybe there is already a variable) |
---|
37 | $advlang = ( isset($user['language']) ) ? |
---|
38 | $user['language'] : $conf['default_language']; // en_UK.iso-8859-1 |
---|
39 | $my_path = dirname(__FILE__).'/'; |
---|
40 | $adv = array(); |
---|
41 | if ( !@file_exists($my_path."$advlang/lang.adv.php") ) |
---|
42 | { |
---|
43 | $advlang = 'en_UK.iso-8859-1'; |
---|
44 | } |
---|
45 | // Include language advices |
---|
46 | @include_once( $my_path."$advlang/lang.adv.php" ); |
---|
47 | |
---|
48 | // If there is an advice |
---|
49 | if ( $cond ) |
---|
50 | { |
---|
51 | $template->set_filenames(array( |
---|
52 | 'admin_advice' => $my_path.'admin_advices.tpl') |
---|
53 | ); |
---|
54 | |
---|
55 | // Random Thumbnail |
---|
56 | $query = ' |
---|
57 | SELECT * |
---|
58 | FROM '.IMAGES_TABLE.' |
---|
59 | ORDER BY RAND(NOW()) |
---|
60 | LIMIT 0, 1 |
---|
61 | ;'; |
---|
62 | $result = pwg_query($query); |
---|
63 | $row = mysql_fetch_assoc($result); |
---|
64 | if ( is_array($row) ) |
---|
65 | { |
---|
66 | $url_modify = get_root_url().'admin.php?page=picture_modify' |
---|
67 | .'&image_id='.$row['id']; |
---|
68 | $url_check = get_themeconf('icon_dir').'/'; |
---|
69 | $url_uncheck = $url_check . 'uncheck'; |
---|
70 | $url_check .= 'check'; |
---|
71 | $picture_id = $row['id']; |
---|
72 | $query = ' |
---|
73 | SELECT * FROM '.IMAGE_TAG_TABLE.' |
---|
74 | WHERE image_id = ' . $picture_id .' |
---|
75 | ;'; |
---|
76 | $tag_count = mysql_num_rows(mysql_query($query)); |
---|
77 | $template->assign_block_vars( |
---|
78 | 'thumbnail', |
---|
79 | array( |
---|
80 | 'IMAGE' => get_thumbnail_url($row), |
---|
81 | 'IMAGE_ALT' => $row['file'], |
---|
82 | 'IMAGE_TITLE' => $row['name'], |
---|
83 | 'METADATA' => (empty($row['date_metadata_update'])) ? |
---|
84 | $url_uncheck : $url_check, |
---|
85 | 'NAME' => (empty($row['name'])) ? |
---|
86 | $url_uncheck : $url_check, |
---|
87 | 'COMMENT' => (empty($row['comment'])) ? |
---|
88 | $url_uncheck : $url_check, |
---|
89 | 'AUTHOR' => (empty($row['author'])) ? |
---|
90 | $url_uncheck : $url_check, |
---|
91 | 'CREATE_DATE' => (empty($row['date_creation'])) ? |
---|
92 | $url_uncheck : $url_check, |
---|
93 | 'TAGS' => ($tag_count == 0) ? |
---|
94 | $url_uncheck : $url_check, |
---|
95 | 'NUM_TAGS' => (string) $tag_count, |
---|
96 | 'U_MODIFY' => $url_modify, |
---|
97 | ) |
---|
98 | ); |
---|
99 | } |
---|
100 | $advice_text = array_shift($adv); |
---|
101 | $template->assign_vars( |
---|
102 | array( |
---|
103 | 'ADVICE_ABOUT' => '$conf[' . "'$confk'] ", |
---|
104 | 'ADVICE_TEXT' => $advice_text, |
---|
105 | ) |
---|
106 | ); |
---|
107 | foreach ($adv as $advice) |
---|
108 | { |
---|
109 | $template->assign_block_vars( |
---|
110 | 'More', |
---|
111 | array( |
---|
112 | 'ADVICE' => $advice |
---|
113 | ) |
---|
114 | ); |
---|
115 | } |
---|
116 | $template->parse('admin_advice'); |
---|
117 | } |
---|
118 | } |
---|
119 | ?> |
---|