예제 #1
0
파일: text.php 프로젝트: rawork/colors-life
 public function getStatic()
 {
     return CUtils::cut_text(parent::getStatic());
 }
예제 #2
0
파일: Unit.php 프로젝트: rawork/colors-life
 function getTableSearchResults($text, $tableName, $where = '', $idName = '', $nName = 'name')
 {
     $ret = array();
     $fields = $this->getSearchFieldsArray($tableName);
     $fields_text = implode(',', $fields);
     $search_query = '';
     if (is_array($text)) {
         $query_text = '';
         foreach ($text as $t) {
             if (strlen($t) > 2) {
                 $query_text .= ($query_text ? ' ' : '') . '+' . $t . '*';
             }
         }
         $search_query = " MATCH(" . $fields_text . ") AGAINST ('" . $query_text . "' IN BOOLEAN MODE)";
     } else {
         $search_query = " MATCH(" . $fields_text . ") AGAINST ('\"" . $text . "\"' IN BOOLEAN MODE)";
     }
     $items = $GLOBALS['db']->getItems('get_search_items', "SELECT id," . $nName . ",name, " . $search_query . " AS coef FROM " . $this->tables[$tableName]->getDBTableName() . " WHERE " . $search_query . ($where ? ' AND ' . $where : '') . ' ORDER BY coef');
     foreach ($items as $a) {
         $ret[] = array('ref' => $this->getSearchResultRef($a, $idName), 'text' => CUtils::cut_text(strip_tags($a[$nName], 150)));
     }
     return $ret;
 }