示例#1
0
 protected function generateEntries($values)
 {
     parent::generateEntries($values);
     $this->_rangeFacetEntries = array();
     foreach ($this->_facetEntries as $entry) {
         $from = (double) $entry->getTerm();
         $to = $from + $this->_gap;
         array_push($this->_rangeFacetEntries, new RangeFacetEntry($from, $to, $entry->getCount()));
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('definition_facet_types', function ($table) {
         $table->increments('id');
         $table->string('facet_name', 255);
     });
     $facet_types = ['rights', 'keyword', 'language', 'theme', 'publisher_name'];
     $facet_type_models = [];
     foreach ($facet_types as $facet) {
         $facet_type = \FacetType::create(['facet_name' => $facet]);
         $facet_type->save();
         if ($facet != 'keyword') {
             $facet_type_model[$facet] = $facet_type;
         } else {
             $facet_type_model['keywords'] = $facet_type;
         }
     }
     Schema::create('definition_facets', function ($table) {
         $table->increments('id');
         $table->integer('definition_id');
         $table->integer('facet_id');
         $table->string('facet_name');
         $table->string('value');
     });
     // Copy all of the facet related info to the new definition_facets table
     $definitions = \Definition::all();
     foreach ($definitions as $definition) {
         foreach ($facet_type_models as $facet_name => $facet_type) {
             if ($facet_name != 'keywords' && !empty($definition->{$facet_name})) {
                 $facet = \Facet::create(['definition_id' => $definition->id, 'facet_id' => $facet_type->id, 'facet_name' => $facet_name, 'value' => $definition->{$facet_name}]);
                 $facet->save();
             } else {
                 // split the keywords
                 if (!empty($definition->keywords)) {
                     $keywords = explode(',', $definition->keywords);
                     foreach ($keywords as $keyword) {
                         $facet = \Facet::create(['definition_id' => $definition->id, 'facet_id' => $facet_type->id, 'facet_name' => 'keyword', 'value' => $keyword]);
                         $facet->save();
                     }
                 }
             }
         }
     }
 }
示例#3
0
 function __construct($field, $num = null, $key = null)
 {
     $type = 'enum';
     parent::__construct($field, $type, $key);
     $this->num = $num;
 }
示例#4
0
 /**
  * Update the facets for a definition
  *
  * @param Eloquent $definition
  *
  * @return void
  */
 private function updateFacets($definition)
 {
     $facet_types = \FacetType::all()->toArray();
     foreach ($definition->facets() as $facet) {
         \Facet::delete($facet['id']);
     }
     foreach ($facet_types as $facet_type) {
         $facet_name = $facet_type['facet_name'];
         if (!empty($definition->{$facet_name})) {
             $facet = \Facet::create(['definition_id' => $definition->id, 'facet_id' => $facet_type['id'], 'facet_name' => $facet_type['facet_name'], 'value' => $definition->{$facet_name}]);
             $facet->save();
         }
     }
     // Process keywords if present
     if (!empty($definition->keywords)) {
         // Split the keywords
         $keywords = explode(',', $definition->keywords);
         foreach ($keywords as $keyword) {
             $facet = \Facet::create(['definition_id' => $definition->id, 'facet_id' => $facet_type['id'], 'facet_name' => 'keyword', 'value' => $keyword]);
             $facet->save();
         }
     }
 }
示例#5
0
 function __construct($field, $key = null)
 {
     $type = 'range';
     parent::__construct($field, $type, $key);
 }
示例#6
0
 function __construct($field, $start, $end, $gap, $key = null)
 {
     $type = 'hist';
     parent::__construct($field, $type, $key);
     $this->range = "[{$start}:{$end}:{$gap}]";
 }
示例#7
0
 public function addFacetByName($facetName, $type)
 {
     $facet = Facet::getCreateByName($facetName);
     $this->facets()->attach($facet->id, array('type' => $type));
 }
 public function contains(Facet $facet)
 {
     return isset($this->facets[$facet->getId()]);
 }