Example #1
0
 /**
  * Register the search and page state of this collection so that the
  * next time that we return to it, we will get the same view.
  * 
  * @return void
  * @access public
  * @since 5/11/06
  */
 function registerState()
 {
     $this->_state = $this->getState($this->getAssetId());
     // unset our starting number if we have the new search terms
     if (RequestContext::value('form_submitted') || isset($_REQUEST[ResultPrinter::startingNumberParam()]) || !isset($this->_state['numPerPage']) || $this->_state['numPerPage'] != $_SESSION['assets_per_page']) {
         $this->_state['startingNumber'] = ResultPrinter::startingNumberParam();
         $this->_state['numPerPage'] = $_SESSION['assets_per_page'];
     } else {
         if (!isset($this->_state['startingNumber'])) {
             $this->_state['startingNumber'] = 1;
             $this->_state['numPerPage'] = $_SESSION['assets_per_page'];
         }
     }
 }
Example #2
0
 /**
  * Register the search and page state of this collection so that the
  * next time that we return to it, we will get the same view.
  * 
  * @return void
  * @access public
  * @since 5/11/06
  */
 function registerState()
 {
     $this->_state = $this->getState($this->getRepositoryId());
     // top-level properties
     $properties = array('limit_by_type' => 'false');
     foreach ($properties as $name => $default) {
         if (RequestContext::value('form_submitted')) {
             $this->_state[$name] = RequestContext::value($name);
         } else {
             if (!isset($this->_state[$name])) {
                 $this->_state[$name] = $default;
             }
         }
     }
     // Search type
     if (RequestContext::value('searchtype')) {
         $this->_state['searchtype'] = HarmoniType::fromString(RequestContext::value('searchtype'));
     } else {
         if (!isset($this->_state['searchtype'])) {
             $this->_state['searchtype'] = new Type("Repository", "edu.middlebury.harmoni", "Keyword", "Search with a string for keywords.");
         }
     }
     // Search Criteria
     $searchModuleManager = Services::getService("RepositorySearchModules");
     if (RequestContext::value('form_submitted')) {
         $this->_state['currentSearchValues'] = $searchModuleManager->getCurrentValues($this->_state['searchtype']);
     } else {
         if (isset($this->_state['currentSearchValues'])) {
             $searchModuleManager->setCurrentValues($this->_state['searchtype'], $this->_state['currentSearchValues']);
         }
     }
     // if we are limiting by type
     if ($this->_state["limit_by_type"] == 'true') {
         if (!isset($this->_state["selectedTypes"])) {
             $this->_state["selectedTypes"] = array();
         }
         $repository = $this->getRepository();
         $types = $repository->getAssetTypes();
         while ($types->hasNext()) {
             $type = $types->next();
             if (RequestContext::value("type___" . $type->asString()) == 'true') {
                 $this->_state["selectedTypes"][$type->asString()] = $type;
             } else {
                 if (RequestContext::value('form_submitted')) {
                     unset($this->_state["selectedTypes"][$type->asString()]);
                 }
             }
         }
     }
     // unset our starting number if we have the new search terms
     if (RequestContext::value('form_submitted') || isset($_REQUEST[ResultPrinter::startingNumberParam()]) || !isset($this->_state['numPerPage']) || $this->_state['numPerPage'] != $_SESSION['assets_per_page']) {
         if (isset($_REQUEST[ResultPrinter::startingNumberParam()])) {
             $this->_state['startingNumber'] = $_REQUEST[ResultPrinter::startingNumberParam()];
         } else {
             $this->_state['startingNumber'] = 1;
         }
         $this->_state['numPerPage'] = $_SESSION['assets_per_page'];
     } else {
         if (!isset($this->_state['startingNumber'])) {
             $this->_state['startingNumber'] = 1;
             $this->_state['numPerPage'] = $_SESSION['assets_per_page'];
         }
     }
 }