Exemple #1
0
 /**
  * 中文转拼音或者英文
  *
  */
 public function zh2pinyin()
 {
     import("@.ORG.pinyin");
     $pinyin = new pinyin();
     if ($_REQUEST['type'] == 'pinyin') {
         echo $pinyin->zh($_REQUEST['text']);
     } elseif ($_REQUEST['type'] == 'pinyin_first_letter') {
         echo $pinyin->first_letter($_REQUEST['text']);
     } else {
         import("@.ORG.GoogleTranslate");
         $GoogleTranslate = new GoogleTranslate();
         echo $GoogleTranslate->code($_REQUEST['text']);
     }
 }
Exemple #2
0
 /**
  * ajax方式检查应用是否存在
  *
  */
 public function check_module()
 {
     $title = $this->_get('title');
     $module_name = $this->_get('module_name');
     if ($_REQUEST['type'] == 'pinyin') {
         import('@.ORG.pinyin');
         $pinyin = new pinyin();
         if ($title) {
             $module_name = $pinyin->zh($title);
         } else {
             $module_name = $pinyin->zh($module_name);
         }
     } else {
         import('@.ORG.GoogleTranslate');
         $GoogleTranslate = new GoogleTranslate();
         if ($title) {
             $module_name = $GoogleTranslate->code($title);
         } else {
             $module_name = $GoogleTranslate->code($module_name);
         }
     }
     $db_node = M('node');
     $count = $db_node->where("name='{$module_name}' AND level=2")->count();
     if ($count < 1) {
         $match = eregi("^[A-Za-z][A-Za-z0-9_]+\$", $module_name);
         if ($match) {
             $module_name = ucfirst($module_name);
             $this->ajaxReturn($module_name, '输入正确', 1);
         } else {
             $this->ajaxReturn('', '只能输入字母、数字和_,第一个字符必需是字母。', 2);
         }
     } else {
         $this->ajaxReturn('', '应用已存在,请重新输入', 3);
     }
 }