예제 #1
0
 }
 // basic
 $vars['@project@'] = is_file($project) ? realpath($project) : $project;
 $vars['@charset@'] = $xs->getDefaultCharset();
 if ($vars['@charset@'] !== 'GB2312' && $vars['@charset@'] !== 'GBK') {
     $vars['@charset@'] = 'UTF-8';
 }
 $vars['@xs_lib_root@'] = XS_LIB_ROOT;
 $vars['@date_time@'] = date('Y-m-d H:i:s');
 $vars['@project_name@'] = ucfirst($xs->name);
 $vars['@package_name@'] = PACKAGE_NAME;
 $vars['@package_version@'] = PACKAGE_VERSION;
 // fields
 $vars['@set_filter@'] = '';
 $vars['@set_sort@'] = '';
 $vars['@field_id@'] = $xs->getFieldId()->name;
 if (($field = $xs->getFieldTitle()) !== false) {
     $vars['@field_title@'] = $field->name;
 }
 if (($field = $xs->getFieldBody()) !== false) {
     $vars['@field_body@'] = $field->name;
 }
 $vars['@field_info@'] = '';
 foreach ($xs->getAllFields() as $field) {
     if ($field->hasIndexSelf() && $field->type != XSFieldMeta::TYPE_BODY && !$field->isBoolIndex()) {
         $vars['@set_filter@'] .= "\t\t\t<label class=\"radio inline\"><input type=\"radio\" name=\"f\" value=\"{$field->name}\" <?php echo \$f_{$field->name}; ?> />" . ucfirst($field->name) . "</label>\n";
     }
     if ($field->isNumeric()) {
         $vars['@set_sort@'] .= "\t\t\t\t\t<option value=\"" . $field->name . "_DESC\" <?php echo \$s_{$field->name}_DESC; ?>>" . ucfirst($field->name) . "从大到小</option>\n";
         $vars['@set_sort@'] .= "\t\t\t\t\t<option value=\"" . $field->name . "_ASC\" <?php echo \$s_{$field->name}_ASC; ?>>" . ucfirst($field->name) . "从小到大</option>\n";
     }
예제 #2
0
파일: Indexer.php 프로젝트: lughong/test
 if ($clean !== null) {
     echo "清空现有索引数据 ...\n";
     $index->clean();
 }
 // stop rebuild
 if ($stop_rebuild !== null) {
     echo "中止索引重建 ...\n";
     $index->stopRebuild();
 }
 // begin rebuild
 if ($rebuild !== null) {
     echo "开始重建索引 ...\n";
     $index->beginRebuild();
 }
 // import data from source
 $fid = $xs->getFieldId();
 if (!empty($source)) {
     echo "初始化数据源 ... {$source} \n";
     $total = $total_ok = $total_failed = 0;
     $src = XSDataSource::instance($source, strpos($source, ':') ? $sql : $file);
     $dcs = $src->getCharset();
     if ($dcs === false) {
         $dcs = $charset === null ? 'UTF-8' : $charset;
     }
     echo "开始批量导入数据 (" . (empty($file) ? "请直接输入数据" : $file) . ") ...\n";
     XSUtil::flush();
     $index->setTimeout(0);
     $index->openBuffer();
     while ($data = $src->getData()) {
         $doc = new XSDocument($dcs);
         if ($source == 'csv') {
예제 #3
0
 public function testGetFieldId()
 {
     $xs3 = new XS("[pid]\ntype=id");
     $f = $xs3->getFieldId();
     $this->assertEquals('pid', $f->name);
     $this->assertEquals(XSFieldMeta::TYPE_ID, $f->type);
     $this->assertTrue($f->isBoolIndex());
     $this->assertTrue($f->hasIndexSelf());
     $this->assertFalse($f->hasIndexMixed());
     $this->assertEquals(1, $f->weight);
     $this->assertTrue($f->hasCustomTokenizer());
     $this->assertInstanceOf('XSTokenizerFull', $f->getCustomTokenizer());
     $this->assertTrue($f->isSpeical());
     $this->assertEquals(0, $f->vno);
 }