Author: sevein
Date: Mon Aug  8 17:25:45 2011
New Revision: 9468

Log:
Add rightsholder module basics

Added:
   trunk/apps/qubit/modules/rightsholder/actions/editAction.class.php
   trunk/apps/qubit/modules/rightsholder/templates/editSuccess.php
Modified:
   trunk/apps/qubit/modules/right/actions/editComponent.class.php
   trunk/apps/qubit/modules/right/templates/_edit.php
   trunk/apps/qubit/modules/rightsholder/templates/listSuccess.php

Modified: trunk/apps/qubit/modules/right/actions/editComponent.class.php
==============================================================================
--- trunk/apps/qubit/modules/right/actions/editComponent.class.php      Mon Aug 
 8 17:24:29 2011        (r9467)
+++ trunk/apps/qubit/modules/right/actions/editComponent.class.php      Mon Aug 
 8 17:25:45 2011        (r9468)
@@ -27,8 +27,8 @@
     'endDate',
     'startDate',
     'restriction',
-    // 'rightsHolder',
-    // 'rightsNote',
+    'rightsHolder',
+    'rightsNote',
     'copyrightStatus',
     'copyrightStatusDate',
     'copyrightJurisdiction',
@@ -105,16 +105,30 @@
 
         break;
 
+      case 'rightsHolder':
+
+        foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::RIGHT_BASIS_ID) as 
$item)
+        {
+          $choices[$this->context->routing->generate(null, array($item, 
'module' => 'term'))] = $item->__toString();
+        }
+
+        $this->form->setValidator('rightsHolder', new sfValidatorString);
+        $this->form->setWidget('rightsHolder', new 
sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true)));
+
+        break;
+
       case 'copyrightJurisdiction':
-        $this->form->setValidator('copyrightJurisdiction', new 
sfValidatorI18nChoiceCountry);
-        $this->form->setWidget('copyrightJurisdiction', new 
sfWidgetFormI18nChoiceCountry(array('add_empty' => true, 'culture' => 
$this->context->user->getCulture())));
+        $this->form->setValidator('copyrightJurisdiction', new 
sfValidatorI18nChoiceCountry(array('multiple' => true)));
+        $this->form->setWidget('copyrightJurisdiction', new 
sfWidgetFormI18nChoiceCountry(array('culture' => 
$this->context->user->getCulture(), 'multiple' => true)));
+
+        break;
 
       case 'copyrightNote':
       case 'licenseNote':
-      case 'restriction':
       case 'statuteJurisdiction':
       case 'statuteCitation':
       case 'statuteNote':
+      case 'rightsNote':
         $this->form->setValidator($name, new sfValidatorString);
         $this->form->setWidget($name, new sfWidgetFormTextarea);
 
@@ -122,6 +136,7 @@
 
       case 'licenseIdentifier':
       case 'licenseTerms':
+      case 'restriction':
         $this->form->setValidator($name, new sfValidatorString);
         $this->form->setWidget($name, new sfWidgetFormInput);
 
@@ -135,6 +150,7 @@
     {
       case 'act':
       case 'basis':
+      case 'copyrightStatus':
         unset($this->right[$field->getName()]);
 
         $value = $this->form->getValue($field->getName());

Modified: trunk/apps/qubit/modules/right/templates/_edit.php
==============================================================================
--- trunk/apps/qubit/modules/right/templates/_edit.php  Mon Aug  8 17:24:29 
2011        (r9467)
+++ trunk/apps/qubit/modules/right/templates/_edit.php  Mon Aug  8 17:25:45 
2011        (r9468)
@@ -136,11 +136,16 @@
 
     <?php echo $form->endDate->renderRow() ?>
 
-    <?php echo $form->basis->renderRow() ?>
+    <div class="form-item">
+      <?php echo $form->rightsHolder->renderLabel() ?>
+      <?php echo $form->rightsHolder->render(array('class' => 
'form-autocomplete')) ?>
+      <input class="add" type="hidden" value="<?php echo 
url_for(array('module' => 'rightsholder', 'action' => 'add')) ?> 
#authorizedFormOfName"/>
+      <input class="list" type="hidden" value="<?php echo 
url_for(array('module' => 'rightsholder', 'action' => 'autocomplete')) ?>"/>
+    </div>
 
-    <?php // rights_holder ?>
+    <?php echo $form->rightsNote->renderRow() ?>
 
-    <?php // rights_note ?>
+    <?php echo $form->basis->renderRow() ?>
 
     <fieldset route="<?php echo $sf_context->routing->generate(null, 
array(QubitTerm::getById(QubitTerm::RIGHT_BASIS_COPYRIGHT_ID), 'module' => 
'term')) ?>">
 
@@ -150,7 +155,7 @@
 
       <?php echo $form->copyrightStatusDate->renderRow() ?>
 
-      <?php echo $form->copyrightJurisdiction->renderRow() ?>
+      <?php echo $form->copyrightJurisdiction->renderRow(array('class' => 
'form-autocomplete')) ?>
 
       <?php echo $form->copyrightNote->renderRow() ?>
 

Added: trunk/apps/qubit/modules/rightsholder/actions/editAction.class.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/apps/qubit/modules/rightsholder/actions/editAction.class.php  Mon Aug 
 8 17:25:45 2011        (r9468)
@@ -0,0 +1,95 @@
+<?php
+
+/*
+ * This file is part of Qubit Toolkit.
+ *
+ * Qubit Toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Qubit Toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Qubit Toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+class RepositoryEditAction extends DefaultEditAction
+{
+  protected function earlyExecute()
+  {
+    $this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
+
+    $this->resource = new QubitRightsHolder;
+
+    if (isset($this->getRoute()->resource))
+    {
+      $this->resource = $this->getRoute()->resource;
+
+      // Check that this isn't the root
+      if (!isset($this->resource->parent))
+      {
+        $this->forward404();
+      }
+
+      // Check user authorization
+      if (!QubitAcl::check($this->resource, 'update'))
+      {
+        QubitAcl::forwardUnauthorized();
+      }
+
+      // Add optimistic lock
+      $this->form->setDefault('serialNumber', $this->resource->serialNumber);
+      $this->form->setValidator('serialNumber', new sfValidatorInteger);
+      $this->form->setWidget('serialNumber', new sfWidgetFormInputHidden);
+    }
+    else
+    {
+      // Check user authorization
+      if (!QubitAcl::check($this->resource, 'create'))
+      {
+        QubitAcl::forwardUnauthorized();
+      }
+    }
+  }
+
+  protected function addField($name)
+  {
+    switch ($name)
+    {
+      case 'authorizedFormOfName':
+        $this->form->setDefault('authorizedFormOfName', 
$this->resource['authorizedFormOfName']);
+        $this->form->setValidator('authorizedFormOfName', new 
sfValidatorString);
+        $this->form->setWidget('authorizedFormOfName', new sfWidgetFormInput);
+
+        break;
+
+      default:
+
+        return parent::addField($name);
+    }
+  }
+
+  public function execute($request)
+  {
+    parent::execute($request);
+
+    if ($request->isMethod('post'))
+    {
+      $this->form->bind($request->getPostParameters());
+      if ($this->form->isValid())
+      {
+        $this->processForm();
+
+        $this->resource->save();
+
+        $this->redirect(array($this->resource, 'module' => 'rightsholder'));
+      }
+    }
+
+    QubitDescription::addAssets($this->response);
+  }
+}

Added: trunk/apps/qubit/modules/rightsholder/templates/editSuccess.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/apps/qubit/modules/rightsholder/templates/editSuccess.php     Mon Aug 
 8 17:25:45 2011        (r9468)
@@ -0,0 +1,43 @@
+<h1><?php echo __('Edit rights holder') ?></h1>
+
+<h1 class="label"><?php echo render_title($resource) ?></h1>
+
+<?php echo $form->renderGlobalErrors() ?>
+
+<?php if (isset($sf_request->getAttribute('sf_route')->resource)): ?>
+  <?php echo $form->renderFormTag(url_for(array($resource, 'module' => 
'rightsholder', 'action' => 'edit')), array('id' => 'editForm')) ?>
+<?php else: ?>
+  <?php echo $form->renderFormTag(url_for(array('module' => 'rightsholder', 
'action' => 'add')), array('id' => 'editForm')) ?>
+<?php endif; ?>
+
+  <?php echo $form->renderHiddenFields() ?>
+
+  <fieldset class="collapsible" id="identityArea">
+
+    <legend><?php echo __('Identity area') ?></legend>
+
+    <?php echo render_field($form->authorizedFormOfName, $resource) ?>
+
+  </fieldset>
+
+  <div class="actions section">
+
+    <h2 class="element-invisible"><?php echo __('Actions') ?></h2>
+
+    <div class="content">
+      <ul class="clearfix links">
+
+        <?php if (isset($sf_request->getAttribute('sf_route')->resource)): ?>
+          <li><input class="form-submit" type="submit" value="<?php echo 
__('Save') ?>"/></li>
+          <li><?php echo link_to(__('Cancel'), array($resource, 'module' => 
'rightsholder'), array('title' => __('Cancel'))) ?></li>
+        <?php else: ?>
+          <li><input class="form-submit" type="submit" value="<?php echo 
__('Create') ?>"/></li>
+          <li><?php echo link_to(__('Cancel'), array('module' => 
'rightsholder', 'action' => 'list'), array('title' => __('Cancel'))) ?></li>
+        <?php endif; ?>
+
+      </ul>
+    </div>
+
+  </div>
+
+</form>

Modified: trunk/apps/qubit/modules/rightsholder/templates/listSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/rightsholder/templates/listSuccess.php     Mon Aug 
 8 17:24:29 2011        (r9467)
+++ trunk/apps/qubit/modules/rightsholder/templates/listSuccess.php     Mon Aug 
 8 17:25:45 2011        (r9468)
@@ -18,7 +18,7 @@
         </th>
       </tr>
     </thead><tbody>
-      <?php foreach ($rightsholders as $item): ?>
+      <?php foreach ($rightsHolders as $item): ?>
         <tr class="<?php echo 0 == ++$row % 2 ? 'even' : 'odd' ?>">
           <td>
             <?php echo link_to(render_title($item), $item) ?>
@@ -35,6 +35,6 @@
 <div class="search">
   <form action="<?php echo url_for(array('module' => 'rightsholder', 'action' 
=> 'list')) ?>">
     <input name="subquery" value="<?php echo 
esc_entities($sf_request->subquery) ?>"/>
-    <input class="form-submit" type="submit" value="<?php echo __('Search 
rights holder')) ?>"/>
+    <input class="form-submit" type="submit" value="<?php echo __('Search 
rights holder') ?>"/>
   </form>
 </div>

-- 
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