functions.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. function get_group_class()
  3. {
  4. global $db;
  5. global $db_mymps;
  6. static $res;
  7. $data = read_static_cache('group_class');
  8. if ($data === false) {
  9. $query = $db->query('SELECT * FROM `' . $db_mymps . 'group_category` WHERE cate_view = \'1\' ORDER BY cate_order ASC');
  10. while ($row = $db->fetchRow($query)) {
  11. $res[$row['cate_id']]['cate_id'] = $row['cate_id'];
  12. $res[$row['cate_id']]['cate_name'] = $row['cate_name'];
  13. $res[$row['cate_id']]['cate_uri'] = plugin_url('group', array('cate_id' => $row['cate_id']));
  14. }
  15. write_static_cache('group_class', $res);
  16. }
  17. else {
  18. $res = $data;
  19. }
  20. return $res;
  21. }
  22. function get_groupclass_select($formname = 'cate_id', $cate_id = '', $ifselect = 'yes')
  23. {
  24. global $db;
  25. global $db_mymps;
  26. $data = get_group_class();
  27. $mymps .= $ifselect == 'yes' ? '<select name="' . $formname . '" id="' . $formname . '" class=input>' : '';
  28. foreach ($data as $k => $v) {
  29. $mymps .= '<option value="' . $v[cate_id] . '"';
  30. $mymps .= $cate_id == $v['cate_id'] ? ' selected style="background-color:#6EB00C;color:white"' : '';
  31. $mymps .= '>' . $v[cate_name] . '</option>';
  32. }
  33. $mymps .= $ifselect == 'yes' ? '</select>' : '';
  34. unset($data);
  35. return $mymps;
  36. }
  37. ?>