dmBridge PHP API
UNLVSpatialCPController.php
00001 <?php
00002 #
00003 # UNLVSpatial: a dmBridge module for spatial content
00004 #
00005 # Copyright © 2011 Board of Regents of the Nevada System of Higher
00006 # Education, on behalf of the University of Nevada, Las Vegas
00007 #
00008 
00016 class UNLVSpatialCPController extends DMCPAdminController {
00017 
00018    public function reindex() {
00019       $this->preFlightCheck();
00020 
00021       if (DMHTTPRequest::getCurrent()->getMethod() == DMHTTPMethod::POST) {
00022          $req = DMHTTPRequest::getCurrent();
00023          $rep = $req->getRepresentation();
00024          $alias = DMCollection::getSanitizedAlias(
00025                $rep->getFormValue("alias"));
00026          $flash = null;
00027          try {
00028             $collection = DMCollectionFactory::getCollection($alias);
00029             $nick = $rep->getFormValue("fields");
00030             $field = $collection->getField($nick[$alias]);
00031 
00032             $indexer = new UNLVSpatialIndexer();
00033             $this->tpl_vars['indexer'] = $indexer;
00034             $indexer->reindex($collection, $field);
00035             $flash = new DMFlash(
00036                sprintf("Indexing complete. %d indexed; %d skipped.",
00037                      count($indexer->getIndexedObjects()),
00038                      count($indexer->getSkippedObjects())),
00039                true);
00040          } catch (DMUnavailableModelException $e) {
00041             $flash = new DMFlash("You must select a collection.", false);
00042          }
00043          DMHTTPRequest::getCurrent()->getSession()->setFlash($flash);
00044       }
00045 
00046       $this->tpl_vars['collections'] = DMCollection::getAuthorized();
00047 
00048       $this->renderModuleTemplate(
00049             dirname(__FILE__) . "/../cp_templates/reindex.html.php");
00050       die;
00051    }
00052 
00053 }
 All Data Structures Functions Variables