function execute( VF_Schema $schema, $alphaNumeric=false ) { $this->alphaNumeric = $alphaNumeric; $this->schema = $schema; $levels = $schema->getLevels(); $c = count( $levels ); $levelFinder = new VF_Level_Finder(); if( isset( $_GET['front'] ) ) { $product = isset($_GET['product']) ? $_GET['product'] : null; if($alphaNumeric) { $children = $levelFinder->listInUseByTitle( new VF_Level($this->requestLevel()), $this->requestLevels(), $product ); } else { $children = $levelFinder->listInUse( new VF_Level($this->requestLevel()), $this->requestLevels(), $product ); } } else { $children = $levelFinder->listAll( $this->requestLevel(), $this->requestLevels() ); } echo $this->renderChildren($children); }
/** @return VF_Level_Finder */ function getFinder() { if (!$this->finder instanceof VF_Level_Finder) { $this->finder = new VF_Level_Finder($this->getSchema()); } $this->finder->setConfig($this->getConfig()); return $this->finder; }
function testNonRootLevel() { $originalVehicle = $this->createMMY('Honda', 'Civic'); $this->startProfiling(); $finder = new VF_Level_Finder(); $modelId = $finder->findEntityIdByTitle('model', 'Civic', $originalVehicle->getValue('make')); $modelId = $finder->findEntityIdByTitle('model', 'Civic', $originalVehicle->getValue('make')); $this->assertEquals(1, $this->getQueryCount()); }
function testShouldSaveLevel() { $schema = VF_Schema::create('foo,bar'); $vehicle = VF_Vehicle::create($schema, array('foo' => 'valfoo', 'bar' => 'valbar')); $vehicle->save(); $levelFinder = new VF_Level_Finder($schema); $foundLevel = $levelFinder->find('foo', $vehicle->getValue('foo')); $this->assertEquals($vehicle->getValue('foo'), $foundLevel->getId(), 'should save & find level'); }
function getLevel($level) { if ($this->hasLoadedLevel($level)) { return $this->levels[$level]; } if ($this->levelIsOutsideFlexibleSelection($level)) { return new VF_Level($level, 0, $this->schema()); } $id = $this->getValue($level); $levelFinder = new VF_Level_Finder($this->schema()); $object = $levelFinder->find($level, $id); if (false == $object) { $object = new VF_Level($level, $id, $this->schema()); if (false == $id) { $title = isset($this->titles[$level]) ? $this->titles[$level] : ''; $object->setTitle($title); } } $this->levels[$level] = $object; return $object; }
function execute(VF_Schema $schema) { $this->legacyNumericSearch = (bool) $this->getConfig()->search->legacyNumericSearch; $this->schema = $schema; $levels = $schema->getLevels(); $c = count($levels); $levelFinder = new VF_Level_Finder($schema); /** @var VF_Level_Finder|VF_Level_Finder_Selector $levelFinder */ if (isset($_GET['front'])) { $product = isset($_GET['product']) ? $_GET['product'] : null; if (!$this->legacyNumericSearch) { if ($this->shouldListAll()) { $levelsToSelect = array($this->requestLevel()); $where = $this->requestLevels(); $vehicleFinder = new VF_Vehicle_Finder($schema); $vehicles = $vehicleFinder->findDistinct($levelsToSelect, $where); $children = array(); foreach ($vehicles as $vehicle) { /** @var VF_Vehicle $vehicle */ array_push($children, $vehicle->getLevel($this->requestLevel())); } } else { $children = $levelFinder->listInUseByTitle(new VF_Level($this->requestLevel()), $this->requestLevels(), $product); } } else { if ($this->shouldListAll()) { $children = $levelFinder->listAll(new VF_Level($this->requestLevel()), $this->requestLevels(), $product); } else { $children = $levelFinder->listInUse(new VF_Level($this->requestLevel()), $this->requestLevels(), $product); } } } else { $children = $levelFinder->listAll($this->requestLevel(), $this->requestLevels()); } echo $this->renderChildren($children); }
function getValueForSelectedLevel($level) { // multi tree integration if ($fit = $this->getRequest()->getParam('fit')) { return $fit; } if (!$this->hasGETRequest() && isset($_SESSION[$level])) { return $_SESSION[$level]; } if (!$this->getRequest()->getParam($level) || 'loading' == $this->getRequest()->getParam($level)) { return false; } if ($this->isNumericRequest()) { return $this->getRequest()->getParam($level); } else { $levelStringValue = $this->getRequest()->getParam($level); $levelFinder = new VF_Level_Finder(); $parentLevel = $this->schema()->getPrevLevel($level); if ($parentLevel) { $parentValue = $this->getValueForSelectedLevel($parentLevel); } else { $parentValue = null; } return $levelFinder->findEntityIdByTitle($level, $levelStringValue, isset($parentValue) ? $parentValue : null); } return false; }
protected function findEntityByTitle($type, $title, $parent_id = 0) { $finder = new VF_Level_Finder(); return $finder->findEntityByTitle($type, $title, $parent_id); }