source: trunk/plugins/admin_advices/main.inc.php @ 1846

Last change on this file since 1846 was 1841, checked in by vdigital, 17 years ago

improvement:

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