コード例 #1
0
<?php

/**
 * This file is part of the sfSearch package.
 * (c) Carl Vondrick <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require dirname(__FILE__) . '/../../bootstrap/unit.php';
require 'document/xfFieldValue.class.php';
require 'document/xfField.class.php';
$t = new lime_test(3, new lime_output_color());
$field = new xfField('name', xfField::KEYWORD);
$field->registerCallback('md5');
$value = new xfFieldValue($field, 'value', 'utf8');
$t->is($value->getField(), $field, '->getField() returns the field');
$t->is($value->getValue(), md5('value'), '->getValue() returns the transformed value');
$t->is($value->getEncoding(), 'utf8', '->getEncoding() returns the encoding');
コード例 #2
0
 /**
  * Processes a field
  *
  * @param xfFieldValue $field
  * @param bool $verbose
  */
 private function processField(xfFieldValue $field, $verbose = false)
 {
     $name = $field->getField()->getName();
     $value = $field->getValue();
     if (strlen($value) > 175 && !$verbose) {
         $value = rtrim(substr($value, 0, 175)) . $this->formatter->format('...', array('fg' => 'red', 'bold' => true));
     }
     if ($field->getField()->getBoost() != 1) {
         $value = $this->formatter->format('B' . number_format($field->getField()->getBoost(), 2), array('fg' => 'yellow', 'bold' => true)) . ' ' . $value;
     }
     $value = wordwrap($value, 66);
     $value = str_replace("\n", "\n" . str_repeat(' ', 17), $value);
     if ($field->getField()->getType() & xfField::INDEXED) {
         $name = '*' . $name;
     }
     $this->outputRow($name, $value, 'green');
 }
コード例 #3
0
 /**
  * Adds a field to the document.
  *
  * @param xfFieldValue $fieldValue The field with a value
  */
 public function addField(xfFieldValue $fieldValue)
 {
     $this->fields[strtolower($fieldValue->getField()->getName())] = $fieldValue;
 }