Author: david
Date: Fri Oct 29 13:55:45 2010
New Revision: 8673

Log:
Use standard form template.

Deleted:
   trunk/lib/form/OaiAddRepositoryForm.class.php
Modified:
   trunk/apps/qubit/modules/oai/actions/harvesterListAction.class.php
   trunk/apps/qubit/modules/oai/templates/harvesterListSuccess.php

Modified: trunk/apps/qubit/modules/oai/actions/harvesterListAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/oai/actions/harvesterListAction.class.php  Fri Oct 
29 13:36:35 2010        (r8672)
+++ trunk/apps/qubit/modules/oai/actions/harvesterListAction.class.php  Fri Oct 
29 13:55:45 2010        (r8673)
@@ -34,7 +34,7 @@
    */
   public function execute($request)
   {
-    $this->form = new OaiAddRepositoryForm();
+    $this->form = new sfForm;
 
     // Get repositories
     $criteria = new Criteria;
@@ -42,46 +42,54 @@
     $criteria->addAscendingOrderByColumn(QubitOaiRepository::NAME);
     $this->repositories = QubitOaiRepository::get($criteria);
 
+    // Add URI field
+    $this->form->setValidator('uri', new sfValidatorUrl(array('required' => 
true)));
+    $this->form->setWidget('uri', new sfWidgetFormInputText);
+
     $this->harvestJob = array();
 
     if ($request->isMethod('post'))
     {
-      $this->form->bind($request->oai_harvester);
+      $this->form->bind($request->getPostParameters());
       if ($this->form->isValid())
       {
-        $harvesterArr = $request->oai_harvester;
-
-        if (count(QubitOaiRepository::getByURI($harvesterArr['uri'])) != 0)
-        {
-           $this->request->setAttribute('preExistingRepository', true);
-           $this->forward('oai', 'harvesterNewRepository');
-        }
-        $URI = $harvesterArr['uri'];
-        $URI .= '?verb=Identify';
-        $oaiSimple = simplexml_load_file($URI);
-        libxml_use_internal_errors(true);
-        if ($oaiSimple)
-        {
-          $repository = new QubitOaiRepository();
-          $Identify = $oaiSimple->Identify;
-
-          $repository->setName($Identify->repositoryName);
-          $repository->setUri($harvesterArr['uri']);
-          $repository->setAdminEmail($Identify->adminEmail);
-          $repository->setEarliestTimestamp($Identify->earliestDatestamp);
-          $repository->save();
-
-          $harvest = new QubitOaiHarvest();
-          $harvest->setOaiRepository($repository);
-          $harvest->setMetadataPrefix('oai_dc');
-          $harvest->save();
-          $this->redirect('oai/harvesterNewRepository');
-        } else
-        {
-          $this->request->setAttribute('parsingErrors', true);
-          $this->forward('oai', 'harvesterNewRepository');
-        }
+        $this->processForm();
       }
     }
   }
+
+  protected function processForm()
+  {
+    if (0 < count(QubitOaiRepository::getByURI($this->form->getValue('uri'))))
+    {
+       $this->request->setAttribute('preExistingRepository', true);
+       $this->forward('oai', 'harvesterNewRepository');
+    }
+
+    $oaiSimple = 
simplexml_load_file("{$this->form->getValue('uri')}?verb=Identify");
+    libxml_use_internal_errors(true);
+
+    if ($oaiSimple)
+    {
+      $repository = new QubitOaiRepository();
+      $Identify = $oaiSimple->Identify;
+
+      $repository->setName($Identify->repositoryName);
+      $repository->setUri($this->form->getValue('uri'));
+      $repository->setAdminEmail($Identify->adminEmail);
+      $repository->setEarliestTimestamp($Identify->earliestDatestamp);
+      $repository->save();
+
+      $harvest = new QubitOaiHarvest();
+      $harvest->setOaiRepository($repository);
+      $harvest->setMetadataPrefix('oai_dc');
+      $harvest->save();
+      $this->redirect('oai/harvesterNewRepository');
+    }
+    else
+    {
+      $this->request->setAttribute('parsingErrors', true);
+      $this->forward('oai', 'harvesterNewRepository');
+    }
+  }
 }

Modified: trunk/apps/qubit/modules/oai/templates/harvesterListSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/oai/templates/harvesterListSuccess.php     Fri Oct 
29 13:36:35 2010        (r8672)
+++ trunk/apps/qubit/modules/oai/templates/harvesterListSuccess.php     Fri Oct 
29 13:55:45 2010        (r8673)
@@ -31,7 +31,7 @@
   <legend><?php echo __('Add New Repository') ?></legend>
 
   <form action="<?php echo url_for('oai/harvesterList') ?>" method="post">
-    <?php echo $form ?>
+    <?php echo $form->uri->renderRow() ?>
     <input class="form-submit" type="submit" value="<?php echo __('Save') ?>"/>
   </form>
 </fieldset>

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to