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

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

Admin Advices now is p0w0 compliant (other themes as well coming).
Admin Advices random thumbnail is partly check (Name, Description, Author, creation date and metadata) well updated or not.
Tags relation will be checked asap for the thumbnail.
More : Thumbnail is directly linked to Modify picture Admin function to make it accurate.

File size: 3.0 KB
Line 
1<?php /*
2Plugin Name: Admin Advices !
3Version: 1.0.0
4Author: PhpWebGallery team
5Description: Give you an advice on the administration page.
6*/
7
8add_event_handler('loc_begin_page_tail', 'set_admin_advice' );
9
10
11function 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 = '
41SELECT *
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        $url_modify = get_root_url().'admin.php?page=picture_modify'
51                    .'&amp;image_id='.$row['id'];
52        $url_check = get_themeconf('icon_dir').'/';
53        $url_uncheck = $url_check . 'uncheck';
54        $url_check .= 'check';       
55        $template->assign_block_vars(
56          'thumbnail',
57           array(
58             'IMAGE'              => get_thumbnail_url($row),
59             'IMAGE_ALT'          => $row['file'],
60             'IMAGE_TITLE'        => $row['name'],
61             'METADATA'           => (empty($row['date_metadata_update'])) ?
62                                     $url_uncheck : $url_check,
63             'NAME'               => (empty($row['name'])) ?
64                                     $url_uncheck : $url_check,
65             'COMMENT'            => (empty($row['comment'])) ?
66                                     $url_uncheck : $url_check,
67             'AUTHOR'             => (empty($row['author'])) ?
68                                     $url_uncheck : $url_check,
69             'CREATE_DATE'        => (empty($row['date_creation'])) ?
70                                     $url_uncheck : $url_check,
71             'U_MODIFY'           => $url_modify,     
72           )
73         );
74      }
75      $advice_text = array_shift($adv);
76      $template->assign_vars(
77        array(
78          'ADVICE_ABOUT' => '$conf[' . "'$confk'] ",
79          'ADVICE_TEXT'  => $advice_text,
80           )
81        );
82      foreach ($adv as $advice)
83      {
84          $template->assign_block_vars(
85            'More',
86            array(
87              'ADVICE' => $advice
88              )
89            );
90      }
91    $template->parse('admin_advice');
92    }
93  }
94}
95?>
Note: See TracBrowser for help on using the repository browser.