예제 #1
0
 private function prepareChildren()
 {
     $collectionList = null;
     try {
         $collectionList = new Solrsearch_Model_CollectionList($this->getRequest()->getParam('id'));
     } catch (Solrsearch_Model_Exception $e) {
         $this->_logger->debug($e->getMessage());
         return $this->_redirectToAndExit('index', '', 'browse', null, array(), true);
     }
     $this->view->collectionId = $collectionList->getCollectionId();
     $this->view->collectionRole = $collectionList->getCollectionRole();
     $this->view->children = $collectionList->getChildren();
     $this->view->parents = $collectionList->getParents();
     $translation = $this->view->translate($collectionList->getCollectionRoleTitle());
     if ($translation === $collectionList->getCollectionRoleTitle()) {
         $translation = $collectionList->getCollectionRoleTitlePlain();
     }
     $this->view->collectionRoleTitle = $translation;
     if ($collectionList->isRootCollection()) {
         $this->view->title = $translation;
     } else {
         $this->view->title = $collectionList->getTitle();
     }
     // Get the theme assigned to this collection iff usertheme is
     // set in the request.  To enable the collection theme, add
     // /usetheme/1/ to the URL.
     $usetheme = $this->getRequest()->getParam("usetheme");
     if (!is_null($usetheme) && 1 === (int) $usetheme) {
         $layoutPath = APPLICATION_PATH . '/public/layouts/' . $collectionList->getTheme();
         if (is_readable($layoutPath . '/common.phtml')) {
             $this->_helper->layout->setLayoutPath($layoutPath);
         } else {
             $this->_logger->debug("The requested theme '" . $collectionList->getTheme() . "' does not exist - use default theme instead.");
         }
     }
 }
 public function testGetParentsOfGrandchildOfRootCollection()
 {
     $rootCollection = $this->getRootCollection(1);
     $childCollections = $rootCollection->getChildren();
     foreach ($childCollections as $childCollection) {
         if ($childCollection->getVisible() === '1') {
             $grandchildCollections = $childCollection->getChildren();
             foreach ($grandchildCollections as $grandchildCollection) {
                 if ($grandchildCollection->getVisible() === '1') {
                     $collectionList = new Solrsearch_Model_CollectionList($grandchildCollection->getId());
                     $parents = $collectionList->getParents();
                     $this->assertEquals(2, count($parents));
                     $this->assertEquals($rootCollection->getId(), $parents[0]->getId());
                     $this->assertEquals($rootCollection->getRole()->getId(), $parents[0]->getRole()->getId());
                     $this->assertEquals($childCollection->getId(), $parents[1]->getId());
                     $this->assertEquals($childCollection->getRole()->getId(), $parents[1]->getRole()->getId());
                 }
             }
         }
     }
 }