dever 4 years ago
parent
commit
15d33ffd03
2 changed files with 15 additions and 6 deletions
  1. 2 2
      app/content/database/xuniren.php
  2. 13 4
      app/content/lib/Manage.php

+ 2 - 2
app/content/database/xuniren.php

@@ -381,8 +381,8 @@ return array
                 'state' => 1,
             ),
             'type' => 'all',
-            'order' => array('reorder' => 'desc', 'id' => 'desc'),
-            'col' => '*',
+            'order' => array('shou' => 'asc', 'reorder' => 'desc', 'id' => 'desc'),
+            'col' => '*|shou',
         ),
     ),
 );

+ 13 - 4
app/content/lib/Manage.php

@@ -91,9 +91,13 @@ class Manage
     {   
         $name = Dever::param('name', $data);
         if ($name) {
-            $pinyin = new zh2py();
-            $shou = $pinyin::conv($name);
-            $shou = strtolower(substr($shou, 0, 1));
+            $first = mb_substr($name, 0, 1);
+            if (preg_match('/^[\x{4e00}-\x{9fa5}]+$/u', $first)) {
+                $pinyin = new zh2py();
+                $first = $pinyin::conv($first);
+            }
+            $shou = strtolower($first);
+
             $update['shou'] = $shou;
             $update['where_id'] = $id;
             Dever::db('content/creater')->update($update);
@@ -104,7 +108,12 @@ class Manage
     {   
         $ename = Dever::param('ename', $data);
         if ($ename) {
-            $shou = strtolower(substr($ename, 0, 1));
+            $first = mb_substr($ename, 0, 1);
+            if (preg_match('/^[\x{4e00}-\x{9fa5}]+$/u', $first)) {
+                $pinyin = new zh2py();
+                $first = $pinyin::conv($first);
+            }
+            $shou = strtolower($first);
 
             $update['shou'] = $shou;
             $update['where_id'] = $id;