[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/includes/ -> functions_selects.php (source)

   1  <?php
   2  /***************************************************************************
   3   *                            function_selects.php
   4   *                            -------------------
   5   *   begin                : Saturday, Feb 13, 2001
   6   *   copyright            : (C) 2001 The phpBB Group
   7   *   email                : support@phpbb.com
   8   *
   9   *   $Id: functions_selects.php 5142 2005-05-06 20:50:13Z acydburn $
  10   *
  11   *
  12   ***************************************************************************/
  13  
  14  /***************************************************************************
  15   *
  16   *   This program is free software; you can redistribute it and/or modify
  17   *   it under the terms of the GNU General Public License as published by
  18   *   the Free Software Foundation; either version 2 of the License, or
  19   *   (at your option) any later version.
  20   *
  21   *
  22   ***************************************************************************/
  23  
  24  //
  25  // Pick a language, any language ...
  26  //
  27  function language_select($default, $select_name = "language", $dirname="language")
  28  {
  29      global $phpEx, $phpbb_root_path;
  30  
  31      $dir = opendir($phpbb_root_path . $dirname);
  32  
  33      $lang = array();
  34      while ( $file = readdir($dir) )
  35      {
  36          if (preg_match('#^lang_#i', $file) && !is_file(@phpbb_realpath($phpbb_root_path . $dirname . '/' . $file)) && !is_link(@phpbb_realpath($phpbb_root_path . $dirname . '/' . $file)))
  37          {
  38              $filename = trim(str_replace("lang_", "", $file));
  39              $displayname = preg_replace("/^(.*?)_(.*)$/", "\\1 [ \\2 ]", $filename);
  40              $displayname = preg_replace("/\[(.*?)_(.*)\]/", "[ \\1 - \\2 ]", $displayname);
  41              $lang[$displayname] = $filename;
  42          }
  43      }
  44  
  45      closedir($dir);
  46  
  47      @asort($lang);
  48      @reset($lang);
  49  
  50      $lang_select = '<select name="' . $select_name . '">';
  51      while ( list($displayname, $filename) = @each($lang) )
  52      {
  53          $selected = ( strtolower($default) == strtolower($filename) ) ? ' selected="selected"' : '';
  54          $lang_select .= '<option value="' . $filename . '"' . $selected . '>' . ucwords($displayname) . '</option>';
  55      }
  56      $lang_select .= '</select>';
  57  
  58      return $lang_select;
  59  }
  60  
  61  //
  62  // Pick a template/theme combo, 
  63  //
  64  function style_select($default_style, $select_name = "style", $dirname = "templates")
  65  {
  66      global $db;
  67  
  68      $sql = "SELECT themes_id, style_name
  69          FROM " . THEMES_TABLE . "
  70          ORDER BY template_name, themes_id";
  71      if ( !($result = $db->sql_query($sql)) )
  72      {
  73          message_die(GENERAL_ERROR, "Couldn't query themes table", "", __LINE__, __FILE__, $sql);
  74      }
  75  
  76      $style_select = '<select name="' . $select_name . '">';
  77      while ( $row = $db->sql_fetchrow($result) )
  78      {
  79          $selected = ( $row['themes_id'] == $default_style ) ? ' selected="selected"' : '';
  80  
  81          $style_select .= '<option value="' . $row['themes_id'] . '"' . $selected . '>' . $row['style_name'] . '</option>';
  82      }
  83      $style_select .= "</select>";
  84  
  85      return $style_select;
  86  }
  87  
  88  //
  89  // Pick a timezone
  90  //
  91  function tz_select($default, $select_name = 'timezone')
  92  {
  93      global $sys_timezone, $lang;
  94  
  95      if ( !isset($default) )
  96      {
  97          $default == $sys_timezone;
  98      }
  99      $tz_select = '<select name="' . $select_name . '">';
 100  
 101      while( list($offset, $zone) = @each($lang['tz']) )
 102      {
 103          $selected = ( $offset == $default ) ? ' selected="selected"' : '';
 104          $tz_select .= '<option value="' . $offset . '"' . $selected . '>' . $zone . '</option>';
 105      }
 106      $tz_select .= '</select>';
 107  
 108      return $tz_select;
 109  }
 110  
 111  ?>


Generated: Mon Jan 14 19:21:40 2013 Cross-referenced by PHPXref 0.7.1