function listEntities($level) { if (!in_array($level, $this->getSchema()->getLevels())) { throw new VF_Level_Exception_InvalidLevel('Invalid level [' . $level . ']'); } $parent_id = 0; $parentLevel = $this->getSchema()->getPrevLevel($level); if ($parentLevel) { $parent_id = $this->getSelected($parentLevel); } $levelObject = new VF_Level($level); if ($this->isNotRootAndHasNoParent($level, $parent_id)) { return array(); } if (!$parentLevel || !$parent_id) { if ($this->shouldListAll()) { return $levelObject->listAll(); } else { return $levelObject->listInUse(array()); } } if ($this->shouldListAll()) { return $levelObject->listAll($parent_id); } else { return $levelObject->listInUse($this->getFlexibleSearch()->getLevelAndValueForSelectedPreviousLevels($level)); } }
function vafDoLevel( $level, $parent_id = 0 ) { $schema = new VF_Schema(); $finder = new VF_Level( $level ); $parentLevel = $schema->getPrevLevel( $level ); if( $parentLevel ) { $entities = $finder->listInUse( array( $parentLevel => $parent_id ) ); } else { $entities = $finder->listInUse(); } echo $level . '["' . $parent_id . '"] = new Array();'; foreach( $entities as $entity ) { ?> var obj = new Array(); obj["title"] = "<?=$entity->getTitle()?>"; obj["id"] = "<?=$entity->getId()?>"; <?=$level?>["<?=$parent_id?>"].push( obj ); <?php if( $level != $schema->getLeafLevel() ) { vafDoLevel( $schema->getNextLevel($level), $entity->getId() ); } echo "\n"; } }
function listEntities($level) { if ($level != $this->searchStrategy->getSchema()->getRootLevel()) { return array(); } $entity = new VF_Level($level); return $entity->listInUse($this->searchStrategy->getRequestLevels(), $this->getProductId()); }
function testShuoldListFromSecondSchema() { $schema = VF_Schema::create('foo,bar'); $vehicle = $this->createVehicle(array('foo' => '123', 'bar' => '456'), $schema); $mapping = new VF_Mapping(1, $vehicle); $mapping->save(); $foo = new VF_Level('foo', null, $schema); $actual = $foo->listInUse(); $this->assertEquals('123', $actual[0], 'should list for level in 2nd schema "foo"'); }
function testShouldNotIncludeOptionsNotInUse() { return $this->markTestIncomplete(); $this->insertProduct('sku1'); $startTime = microtime(); $year = new VF_Level('year'); $year->listInUse(); $endTime = microtime(); echo $endTime-$startTime; //$this->assertTrue( $endTime - $startTime < .03, 'should take less than this much time to list stuff'); }
function testYearAsc() { $schemaGenerator = new VF_Schema_Generator(); $schemaGenerator->setSorting('year', 'asc'); $schema = new VF_Schema(); $this->assertEquals('asc', $schema->getSorting('year')); $vehicle1 = $this->createMMY('Honda', 'Civic', '1999'); $vehicle2 = $this->createMMY('Honda', 'Civic', '2000'); $vehicle3 = $this->createMMY('Honda', 'Civic', '2001'); $this->insertMappingMMY($vehicle1); $this->insertMappingMMY($vehicle2); $this->insertMappingMMY($vehicle3); $year = new VF_Level('year'); $actual = $year->listInUse(array('model' => $vehicle1->getLevel('model')->getId())); $this->assertEquals("1999", $actual[0]->getTitle(), 'should return years, in ASC order'); $this->assertEquals("2000", $actual[1]->getTitle(), 'should return years, in ASC order'); $this->assertEquals("2001", $actual[2]->getTitle(), 'should return years, in ASC order'); }
function getItems() { $make = new VF_Level('make'); return $make->listInUse(); }
function listEntities( $level ) { if(!in_array($level,$this->getSchema()->getLevels())) { throw new VF_Level_Exception_InvalidLevel('Invalid level ['.$level.']'); } $parent_id = 0; $parentLevel = $this->getSchema()->getPrevLevel( $level ); if( $parentLevel ) { $parent_id = $this->getSelected( $parentLevel ); } $levelObject = new VF_Level( $level ); if( $this->isNotRootAndHasNoParent( $level, $parent_id ) ) { return array(); } if( !$parentLevel || !$parent_id ) { return $levelObject->listInUse( array() ); } return $levelObject->listInUse( array($parentLevel=>$parent_id) ); }