aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/admin_advices/main.inc.php
blob: e94da7c095f8109d29ca3843d43798f68d99ab71 (plain)
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
<?php /*
Plugin Name: Admin Advices !
Version: 1.0.0
Author: PhpWebGallery team
Description: Give you an advice on the administration page.
*/
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery                           |
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | branch        : BSF (Best So Far)
// | file          : $URL$
// | last update   : $Date$
// | last modifier : $Author$
// | revision      : $Rev$
// +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify  |
// | it under the terms of the GNU General Public License as published by  |
// | the Free Software Foundation                                          |
// |                                                                       |
// | This program is distributed in the hope that it will be useful, but   |
// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
// | General Public License for more details.                              |
// |                                                                       |
// | You should have received a copy of the GNU General Public License     |
// | along with this program; if not, write to the Free Software           |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA.                                                                  |
// +-----------------------------------------------------------------------+

add_event_handler('loc_begin_page_tail', 'set_admin_advice' );
add_event_handler('loc_end_page_header', 'set_admin_advice_add_css' );

// Add a XHTML tag in HEAD section
function set_admin_advice_add_css()
{
  global $template;
        $template->assign_block_vars(
          'head_element',
           array(
             'CONTENT' => '<link rel="stylesheet" type="text/css" ' 
                        . 'href="plugins/admin_advices/default-layout.css" />',     
           )
         );
}

// Build an advice on the Admin Intro page
function set_admin_advice()
{
  global $page, $user, $template, $conf;


  // This Plugin works only on the Admin page
  if ( isset($page['body_id']) and $page['body_id']=='theAdminPage'
    and $page['page'] == 'intro'
    )
  {
  // Setup Advice Language (Maybe there is already a variable)
    $advlang = ( isset($user['language']) ) ?
      $user['language'] : $conf['default_language']; // en_UK.iso-8859-1

    $adv = array();
    if ( !@file_exists(PHPWG_ROOT_PATH 
         . "plugins/admin_advices/$advlang/lang.adv.php") )
    {
      $advlang = 'en_UK.iso-8859-1';
    }
//  Include language advices
    @include_once( PHPWG_ROOT_PATH
      . "plugins/admin_advices/$advlang/lang.adv.php" );

//  If there is an advice
    if ( $cond )
    {
      $template->set_filenames(array(
        'admin_advice' =>
          PHPWG_ROOT_PATH.'/plugins/admin_advices/admin_advices.tpl')
        );

// Random Thumbnail
      $query = '
SELECT *
  FROM '.IMAGES_TABLE.' 
  ORDER BY RAND(NOW())
  LIMIT 0, 1
;';
      $result = pwg_query($query);
      $row = mysql_fetch_assoc($result);
      if ( is_array($row) )
      {
        $url_modify = get_root_url().'admin.php?page=picture_modify'
                    .'&amp;image_id='.$row['id'];
        $url_check = get_themeconf('icon_dir').'/';
        $url_uncheck = $url_check . 'uncheck';
        $url_check .= 'check'; 
        $picture_id = $row['id']; 
        $query = '
SELECT * FROM '.IMAGE_TAG_TABLE.' 
WHERE image_id =  ' . $picture_id .'
;';
        $tag_count = mysql_num_rows(mysql_query($query)); 
        $template->assign_block_vars(
          'thumbnail',
           array(
             'IMAGE'              => get_thumbnail_url($row),
             'IMAGE_ALT'          => $row['file'],
             'IMAGE_TITLE'        => $row['name'],
             'METADATA'           => (empty($row['date_metadata_update'])) ?
                                     $url_uncheck : $url_check,
             'NAME'               => (empty($row['name'])) ?
                                     $url_uncheck : $url_check,
             'COMMENT'            => (empty($row['comment'])) ?
                                     $url_uncheck : $url_check,
             'AUTHOR'             => (empty($row['author'])) ?
                                     $url_uncheck : $url_check,
             'CREATE_DATE'        => (empty($row['date_creation'])) ?
                                     $url_uncheck : $url_check,
             'TAGS'               => ($tag_count == 0) ?
                                     $url_uncheck : $url_check,
             'NUM_TAGS'           => (string) $tag_count,
             'U_MODIFY'           => $url_modify,     
           )
         );
      }
      $advice_text = array_shift($adv);
      $template->assign_vars(
        array(
          'ADVICE_ABOUT' => '$conf[' . "'$confk'] ",
          'ADVICE_TEXT'  => $advice_text,
           )
        );
      foreach ($adv as $advice)
      {
          $template->assign_block_vars(
            'More',
            array(
              'ADVICE' => $advice
              )
            );
      }
    $template->parse('admin_advice');
    }
  }
}
?>