Changeset 25979


Ignore:
Timestamp:
Dec 17, 2013, 12:14:08 PM (7 years ago)
Author:
mistic100
Message:

remove useless SQL queries, don't change user on admin pages, fix theme and language overwrites, fix toolbar overlap, colorbox max width

Location:
extensions/AdminTools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/AdminTools/include/MultiView.class.php

    r25915 r25979  
    1212  /** @var array $data */
    1313  private $data = array();
     14  private $data_url_params = array();
    1415
    1516  /** @var array $user */
     
    3637      pwg_get_session_var('multiview', array())
    3738      );
     39
     40    $this->data_url_params = array_keys($this->data);
     41    $this->data_url_params = array_map(create_function('$d', 'return "ato_".$d;'), $this->data_url_params);
    3842  }
    3943
     
    8084    if (script_basename() == 'picture')
    8185    {
    82       $url = duplicate_picture_url(array(), array_keys($this->data));
     86      $url = duplicate_picture_url(array(), $this->data_url_params);
    8387    }
    8488    else if (script_basename() == 'index')
    8589    {
    86       $url = duplicate_index_url(array(), array_keys($this->data));
     90      $url = duplicate_index_url(array(), $this->data_url_params);
    8791    }
    8892    else
    8993    {
    90       $url = get_query_string_diff(array_keys($this->data));
     94      $url = get_query_string_diff($this->data_url_params);
    9195    }
    9296
     
    111115      'id' => $user['id'],
    112116      'username' => $user['username'],
     117      'language' => $user['language'],
     118      'theme' => $user['theme'],
    113119      );
    114120
     
    130136
    131137      // view_as
    132       if (isset($_GET['ato_view_as']))
    133       {
    134         $this->data['view_as'] = (int)$_GET['ato_view_as'];
    135       }
    136       if ($this->data['view_as'] != $user['id'])
    137       {
    138         $user = build_user($this->data['view_as'], true);
    139         $this->data['theme'] = $user['theme'];
    140         $this->data['lang'] = $user['language'];
     138      if (!defined('IN_ADMIN'))
     139      {
     140        if (isset($_GET['ato_view_as']))
     141        {
     142          $this->data['view_as'] = (int)$_GET['ato_view_as'];
     143        }
     144        if ($this->data['view_as'] != $user['id'])
     145        {
     146          $user = build_user($this->data['view_as'], true);
     147          if (isset($_GET['ato_view_as']))
     148          {
     149            $this->data['theme'] = $user['theme'];
     150            $this->data['lang'] = $user['language'];
     151          }
     152        }
    141153      }
    142154
     
    195207      $this->save();
    196208    }
     209  }
     210
     211  /**
     212   * Returns the language of the current user if different from the current language
     213   * false otherwise
     214   */
     215  function get_user_language()
     216  {
     217    if (isset($this->user['language']) && isset($this->data['lang'])
     218        && $this->user['language'] != $this->data['lang']
     219      )
     220    {
     221      return $this->user['language'];
     222    }
     223    return false;
    197224  }
    198225
  • extensions/AdminTools/include/events.inc.php

    r25916 r25979  
    2626    $tpl_vars['DELETE_CACHE'] =     isset($conf['multiview_invalidate_cache']);
    2727
    28     include_once(PHPWG_ROOT_PATH . 'include/functions_mail.inc.php');
    29     switch_lang_to(get_default_language());
     28    if (($admin_lang = $MultiView->get_user_language()) !== false)
     29    {
     30      include_once(PHPWG_ROOT_PATH . 'include/functions_mail.inc.php');
     31      switch_lang_to($admin_lang);
     32    }
    3033  }
    3134  else if (script_basename() == 'picture' and $picture['current']['added_by'] == $user['id'])
     
    7679          );
    7780
    78         $query = '
    79 SELECT id FROM ' . CATEGORIES_TABLE.'
    80   WHERE id = ' . $page['category']['id'] .'
    81     AND representative_picture_id = ' . $page['image_id'] .'
    82 ;';
    83         $tpl_vars['IS_REPRESENTATIVE'] = pwg_db_num_rows(pwg_query($query)) > 0;
     81        $tpl_vars['IS_REPRESENTATIVE'] = $page['category']['representative_picture_id'] == $page['image_id'];
    8482      }
    8583
     
    167165  $template->parse('ato_public_controller');
    168166
    169   if ($MultiView->is_admin())
     167  if ($MultiView->is_admin() && @$admin_lang !== false)
    170168  {
    171169    switch_lang_back();
  • extensions/AdminTools/template/public_controller.js

    r25924 r25979  
    66
    77  var $ato = $('#ato_header'),
    8       $ato_closed = $('#ato_header_closed');
     8      $ato_closed = $('#ato_header_closed'),
     9      ato_height = 28; // normal height, real height conputed on init()
    910
    1011  // move to whole page down or up
    1112  function moveBody(dir, anim) {
    12     var operator = dir=='show' ? '+=' : '-=',
    13         ato_height = $ato.height();
     13    var operator = dir=='show' ? '+=' : '-=';
    1414
    1515    if (anim) {
     
    103103  this.init = function(urlSelf) {
    104104    $('body').prepend($ato); // ensure the bar is at the begining
     105   
     106    $ato.show();
     107    ato_height = $ato.height();
    105108
    106109    if ('localStorage' in window) {
     
    110113
    111114      if (window.localStorage.ato_panel_open == "true") {
    112         $ato.show();
    113115        moveBody('show', false);
    114116      }
    115117      else {
     118        $ato.hide();
    116119        $ato_closed.show();
    117120      }
     
    264267      transition: 'none',
    265268      width: 500,
     269      maxWidth: '100%',
    266270      top: 50,
    267271      title: $ato_edit.attr('title'),
  • extensions/AdminTools/template/style.css

    r25924 r25979  
    4848  overflow:visible;
    4949}
     50  #ato_header>ul>li a {
     51    color:white;
     52  }
    5053  #ato_header>ul>li.right {
    5154    float:right;
Note: See TracChangeset for help on using the changeset viewer.