Esempio n. 1
0
 public static function keyWordValid($keyword)
 {
     if (SystemConfig::getBooleanSystemConf(Constants::SYS_CONF_OPEN_FILTER_KEYWORD, false)) {
         $keywords = SystemConfig::getStringSystemConf(Constants::SYS_CONF_FILTER_KEYWORD_KEY, '');
         if (!FilterUtils::isN($keywords)) {
             $keywordArray = explode("{Array}", str_replace(Chr(13), "{Array}", str_replace(Chr(10), "", trim($keywords))));
             foreach ($keywordArray as $keywordS) {
                 $keywordS = trim($keywordS);
                 if (strpos($keyword, $keywordS) !== false || strpos($keywordS, $keyword) !== false) {
                     return false;
                 }
             }
         }
     }
     return true;
 }
 function actionSearchCapital()
 {
     header('Content-type: application/json');
     if (!IjoyPlusServiceUtils::validateAPPKey()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID);
         return;
     }
     $keyword = Yii::app()->request->getParam("keyword");
     if (!(isset($keyword) && !is_null($keyword) && strlen($keyword) > 0)) {
         IjoyPlusServiceUtils::exportServiceError(Constants::KEYWORD_IS_NULL);
         return;
     }
     $keyword = trim($keyword);
     if (!FilterUtils::keyWordValid($keyword)) {
         IjoyPlusServiceUtils::exportEntity(array('results' => array()));
         return;
     }
     $keyword = strtr($keyword, array('%' => '\\%', '_' => '\\_'));
     $page_size = Yii::app()->request->getParam("page_size");
     $page_num = Yii::app()->request->getParam("page_num");
     if (!(isset($page_size) && is_numeric($page_size))) {
         $page_size = 10;
         $page_num = 1;
     } else {
         if (!(isset($page_num) && is_numeric($page_num))) {
             $page_num = 1;
         }
     }
     $type = Yii::app()->request->getParam("type");
     try {
         $prods = SearchManager::searchProgramCapitalByType($keyword, $type, $page_size, $page_size * ($page_num - 1));
         if (isset($prods) && is_array($prods)) {
             IjoyPlusServiceUtils::exportEntity(array('results' => $prods));
         } else {
             IjoyPlusServiceUtils::exportEntity(array('results' => array()));
         }
     } catch (Exception $e) {
         var_dump($e);
         IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR);
     }
 }