Ignore:
Timestamp:
Dec 7, 2013, 6:43:09 PM (10 years ago)
Author:
mistic100
Message:

load tags,themes,users,languages list in AJAX + move javascript code to external file

Location:
extensions/AdminTools/include
Files:
2 edited

Legend:

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

    r25791 r25817  
    212212    }
    213213  }
     214 
     215  /**
     216   * Register custom API methods
     217   */
     218  public static function register_ws($arr)
     219  {
     220    $service = &$arr[0];
     221   
     222    $service->addMethod(
     223      'multiView.getData',
     224      array('MultiView', 'ws_get_data'),
     225      array(),
     226      'AdminTools private method.',
     227      null,
     228      array('admin_only' => true, 'hidden' => true)
     229      );
     230  }
     231 
     232  /**
     233   * API method
     234   * Return full list of users, themes and languages
     235   */
     236  public static function ws_get_data($params)
     237  {
     238    global $conf;
     239   
     240    // get users
     241    $query = '
     242SELECT
     243  '.$conf['user_fields']['id'].' AS id,
     244  '.$conf['user_fields']['username'].' AS username
     245FROM '.USERS_TABLE.'
     246  ORDER BY CONVERT('.$conf['user_fields']['username'].', CHAR)
     247;';
     248    $out['users'] = array_from_query($query);
     249
     250    // get themes
     251    include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php');
     252    $themes = new themes();
     253    foreach (array_keys($themes->db_themes_by_id) as $theme)
     254    {
     255      if (!empty($theme))
     256      {
     257        $out['themes'][] = $theme;
     258      }
     259    }
     260
     261    // get languages
     262    foreach (get_languages() as $code => $name)
     263    {
     264      $out['languages'][] = array(
     265        'id' => $code,
     266        'name' => $name,
     267        );
     268    }
     269   
     270    return $out;
     271  }
    214272}
  • extensions/AdminTools/include/events.inc.php

    r25791 r25817  
    8181      );
    8282
    83     // gets tags
     83    // gets tags (full available list is loaded in ajax)
    8484    $query = '
    8585SELECT id, name
     
    8989;';
    9090    $tag_selection = get_taglist($query);
    91 
    92     $query = '
    93 SELECT id, name
    94   FROM '.TAGS_TABLE.'
    95 ;';
    96     $tags = get_taglist($query, false);
    9791
    9892    $tpl_vars['QUICK_EDIT'] = array(
     
    10599      'date_creation_time' => substr($picture['current']['date_creation'], 11, 5),
    106100      'tag_selection' =>      $tag_selection,
    107       'tags' =>               $tags,
    108101      );
    109102  }
     
    146139      $tpl_vars['QUICK_EDIT']['img'] = DerivativeImage::get_one(IMG_SQUARE, $image_infos)->get_url();
    147140    }
    148   }
    149 
    150 
    151   // get users
    152   $query = '
    153 SELECT
    154   '.$conf['user_fields']['id'].' AS id,
    155   '.$conf['user_fields']['username'].' AS username
    156 FROM '.USERS_TABLE.'
    157   ORDER BY CONVERT('.$conf['user_fields']['username'].', CHAR)
    158 ;';
    159   $tpl_vars['USERS'] = simple_hash_from_query($query, 'id', 'username');
    160 
    161   // get themes
    162   include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php');
    163   $themes = new themes();
    164   foreach (array_keys($themes->db_themes_by_id) as $theme)
    165   {
    166     if (!empty($theme))
    167     {
    168       $tpl_vars['THEMES'][$theme] = $theme;
    169     }
    170   }
    171 
    172   // get languages
    173   foreach (get_languages() as $code => $name)
    174   {
    175     $tpl_vars['LANGS'][$code] = $name;
    176141  }
    177142
Note: See TracChangeset for help on using the changeset viewer.