Changeset 1749 for trunk/plugins


Ignore:
Timestamp:
Jan 24, 2007, 1:09:02 AM (17 years ago)
Author:
rvelices
Message:
  • admin language Statistics (fix annoying message with debug_l10n)
  • somme corrections for admin_advices (css with root_url and only when needed)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/admin_advices/main.inc.php

    r1724 r1749  
    3030// +-----------------------------------------------------------------------+
    3131
    32 add_event_handler('loc_begin_page_tail', 'set_admin_advice' );
    3332add_event_handler('loc_end_page_header', 'set_admin_advice_add_css' );
    3433
     
    3635function set_admin_advice_add_css()
    3736{
    38   global $template;
    39         $template->assign_block_vars(
    40           'head_element',
    41            array(
    42              'CONTENT' => '<link rel="stylesheet" type="text/css" '
    43                         . 'href="plugins/admin_advices/default-layout.css" />',     
    44            )
    45          );
     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  }
    4651}
    4752
     
    5156  global $page, $user, $template, $conf;
    5257
    53 
    54   // This Plugin works only on the Admin page
    55   if ( isset($page['body_id']) and $page['body_id']=='theAdminPage'
    56     and $page['page'] == 'intro'
    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") )
    5864  {
    59   // Setup Advice Language (Maybe there is already a variable)
    60     $advlang = ( isset($user['language']) ) ?
    61       $user['language'] : $conf['default_language']; // en_UK.iso-8859-1
    62 
    63     $adv = array();
    64     if ( !@file_exists(PHPWG_ROOT_PATH
    65          . "plugins/admin_advices/$advlang/lang.adv.php") )
    66     {
    67       $advlang = 'en_UK.iso-8859-1';
    68     }
     65    $advlang = 'en_UK.iso-8859-1';
     66  }
    6967//  Include language advices
    70     @include_once( PHPWG_ROOT_PATH
    71       . "plugins/admin_advices/$advlang/lang.adv.php" );
     68  @include_once( $my_path."$advlang/lang.adv.php" );
    7269
    7370//  If there is an advice
    74     if ( $cond )
    75     {
    76       $template->set_filenames(array(
    77         'admin_advice' =>
    78           PHPWG_ROOT_PATH.'/plugins/admin_advices/admin_advices.tpl')
    79         );
     71  if ( $cond )
     72  {
     73    $template->set_filenames(array(
     74      'admin_advice' => $my_path.'admin_advices.tpl')
     75      );
    8076
    8177// Random Thumbnail
     78    $query = '
     79SELECT *
     80FROM '.IMAGES_TABLE.'
     81ORDER BY RAND(NOW())
     82LIMIT 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                  .'&amp;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'];
    8294      $query = '
    83 SELECT *
    84   FROM '.IMAGES_TABLE.'
    85   ORDER BY RAND(NOW())
    86   LIMIT 0, 1
    87 ;';
    88       $result = pwg_query($query);
    89       $row = mysql_fetch_assoc($result);
    90       if ( is_array($row) )
    91       {
    92         $url_modify = get_root_url().'admin.php?page=picture_modify'
    93                     .'&amp;image_id='.$row['id'];
    94         $url_check = get_themeconf('icon_dir').'/';
    95         $url_uncheck = $url_check . 'uncheck';
    96         $url_check .= 'check';
    97         $picture_id = $row['id'];
    98         $query = '
    9995SELECT * FROM '.IMAGE_TAG_TABLE.'
    10096WHERE image_id =  ' . $picture_id .'
    10197;';
    102         $tag_count = mysql_num_rows(mysql_query($query));
     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    {
    103131        $template->assign_block_vars(
    104           'thumbnail',
    105            array(
    106              'IMAGE'              => get_thumbnail_url($row),
    107              'IMAGE_ALT'          => $row['file'],
    108              'IMAGE_TITLE'        => $row['name'],
    109              'METADATA'           => (empty($row['date_metadata_update'])) ?
    110                                      $url_uncheck : $url_check,
    111              'NAME'               => (empty($row['name'])) ?
    112                                      $url_uncheck : $url_check,
    113              'COMMENT'            => (empty($row['comment'])) ?
    114                                      $url_uncheck : $url_check,
    115              'AUTHOR'             => (empty($row['author'])) ?
    116                                      $url_uncheck : $url_check,
    117              'CREATE_DATE'        => (empty($row['date_creation'])) ?
    118                                      $url_uncheck : $url_check,
    119              'TAGS'               => ($tag_count == 0) ?
    120                                      $url_uncheck : $url_check,
    121              'NUM_TAGS'           => (string) $tag_count,
    122              'U_MODIFY'           => $url_modify,     
    123            )
    124          );
    125       }
    126       $advice_text = array_shift($adv);
    127       $template->assign_vars(
    128         array(
    129           'ADVICE_ABOUT' => '$conf[' . "'$confk'] ",
    130           'ADVICE_TEXT'  => $advice_text,
    131            )
    132         );
    133       foreach ($adv as $advice)
    134       {
    135           $template->assign_block_vars(
    136             'More',
    137             array(
    138               'ADVICE' => $advice
    139               )
    140             );
    141       }
    142     $template->parse('admin_advice');
     132          'More',
     133          array(
     134            'ADVICE' => $advice
     135            )
     136          );
    143137    }
     138  $template->parse('admin_advice');
    144139  }
    145140}
Note: See TracChangeset for help on using the changeset viewer.