Author: sevein
Date: Mon Jul 11 20:19:55 2011
New Revision: 9281
Log:
browse/list/delete actions for donors
Added:
trunk/plugins/qtAccessionPlugin/modules/donor/actions/browseAction.class.php
trunk/plugins/qtAccessionPlugin/modules/donor/actions/deleteAction.class.php
trunk/plugins/qtAccessionPlugin/modules/donor/actions/listAction.class.php
trunk/plugins/qtAccessionPlugin/modules/donor/templates/browseSuccess.php
trunk/plugins/qtAccessionPlugin/modules/donor/templates/deleteSuccess.php
Modified:
trunk/plugins/qtAccessionPlugin/modules/donor/templates/listSuccess.php
Added:
trunk/plugins/qtAccessionPlugin/modules/donor/actions/browseAction.class.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++
trunk/plugins/qtAccessionPlugin/modules/donor/actions/browseAction.class.php
Mon Jul 11 20:19:55 2011 (r9281)
@@ -0,0 +1,73 @@
+<?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 DonorBrowseAction extends sfAction
+{
+ public function execute($request)
+ {
+ if (!isset($request->limit))
+ {
+ $request->limit = sfConfig::get('app_hits_per_page');
+ }
+
+ $criteria = new Criteria;
+
+ // Do source culture fallback
+ $criteria = QubitCultureFallback::addFallbackCriteria($criteria,
'QubitActor');
+
+ switch ($request->sort)
+ {
+ case 'nameDown':
+ $criteria->addDescendingOrderByColumn('authorized_form_of_name');
+
+ break;
+
+ case 'nameUp':
+ $criteria->addAscendingOrderByColumn('authorized_form_of_name');
+
+ break;
+
+ case 'updatedDown':
+ $criteria->addDescendingOrderByColumn(QubitObject::UPDATED_AT);
+
+ break;
+
+ case 'updatedUp':
+ $criteria->addAscendingOrderByColumn(QubitObject::UPDATED_AT);
+
+ break;
+
+ default:
+ if (!$this->getUser()->isAuthenticated())
+ {
+ $criteria->addAscendingOrderByColumn('authorized_form_of_name');
+ }
+ else
+ {
+ $criteria->addDescendingOrderByColumn(QubitObject::UPDATED_AT);
+ }
+ }
+
+ // Page results
+ $this->pager = new QubitPager('QubitDonor');
+ $this->pager->setCriteria($criteria);
+ $this->pager->setMaxPerPage($request->limit);
+ $this->pager->setPage($request->page);
+ }
+}
Added:
trunk/plugins/qtAccessionPlugin/modules/donor/actions/deleteAction.class.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++
trunk/plugins/qtAccessionPlugin/modules/donor/actions/deleteAction.class.php
Mon Jul 11 20:19:55 2011 (r9281)
@@ -0,0 +1,35 @@
+<?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 DonorDeleteAction extends sfAction
+{
+ public function execute($request)
+ {
+ $this->form = new sfForm;
+
+ $this->resource = $this->getRoute()->resource;
+
+ if ($request->isMethod('delete'))
+ {
+ $this->resource->delete();
+
+ $this->redirect(array('module' => 'donor', 'action' => 'browse'));
+ }
+ }
+}
Added:
trunk/plugins/qtAccessionPlugin/modules/donor/actions/listAction.class.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/plugins/qtAccessionPlugin/modules/donor/actions/listAction.class.php
Mon Jul 11 20:19:55 2011 (r9281)
@@ -0,0 +1,73 @@
+<?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 DonorListAction extends sfAction
+{
+ public function execute($request)
+ {
+ if (!isset($request->limit))
+ {
+ $request->limit = sfConfig::get('app_hits_per_page');
+ }
+
+ if (isset($request->subquery))
+ {
+ try
+ {
+ // Parse query string
+ $query = QubitSearch::getInstance()->parse($request->subquery);
+ }
+ catch (Exception $e)
+ {
+ $this->error = $e->getMessage();
+
+ return;
+ }
+ }
+
+ $query->addSubquery(QubitSearch::getInstance()->addTerm('QubitDonor',
'className'), true);
+
+ $this->pager = new QubitArrayPager;
+
+ try
+ {
+ $this->pager->hits =
QubitSearch::getInstance()->getEngine()->getIndex()->find($query);
+ }
+ catch (Exception $e)
+ {
+ $this->error = $e->getMessage();
+
+ return;
+ }
+
+ $this->pager->setMaxPerPage($request->limit);
+ $this->pager->setPage($request->page);
+
+ $ids = array();
+ foreach ($this->pager->getResults() as $hit)
+ {
+ $ids[] = $hit->getDocument()->id;
+ }
+
+ $criteria = new Criteria;
+ $criteria->add(QubitDonor::ID, $ids, Criteria::IN);
+
+ $this->donors = QubitDonor::get($criteria);
+ }
+}
Added: trunk/plugins/qtAccessionPlugin/modules/donor/templates/browseSuccess.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/plugins/qtAccessionPlugin/modules/donor/templates/browseSuccess.php
Mon Jul 11 20:19:55 2011 (r9281)
@@ -0,0 +1,63 @@
+<?php use_helper('Date') ?>
+
+<div class="section tabs">
+
+ <h2 class="element-invisible"><?php echo __('Donor browse options') ?></h2>
+
+ <div class="content">
+ <ul class="clearfix links">
+ <li<?php if ('nameDown' != $sf_request->sort && 'nameUp' !=
$sf_request->sort): ?> class="active"<?php endif; ?>><?php echo
link_to(__('Recent changes'), array('sort' => 'updatedDown') +
$sf_request->getParameterHolder()->getAll(), array('title' => __('Sort')))
?></li>
+ <li<?php if ('nameDown' == $sf_request->sort || 'nameUp' ==
$sf_request->sort): ?> class="active"<?php endif; ?>><?php echo
link_to(__('Alphabetic'), array('sort' => 'nameUp') +
$sf_request->getParameterHolder()->getAll(), array('title' => __('Sort')))
?></li>
+ </ul>
+ </div>
+
+</div>
+
+<h1><?php echo __('Browse donor') ?></h1>
+
+<table class="sticky-enabled">
+ <thead>
+ <tr>
+ <th>
+ <?php echo __('Name') ?>
+ <?php if ('nameDown' == $sf_request->sort): ?>
+ <?php echo link_to(image_tag('up.gif'), array('sort' => 'nameUp') +
$sf_request->getParameterHolder()->getAll(), array('title' => __('Sort'))) ?>
+ <?php elseif ('nameUp' == $sf_request->sort): ?>
+ <?php echo link_to(image_tag('down.gif'), array('sort' =>
'nameDown') + $sf_request->getParameterHolder()->getAll(), array('title' =>
__('Sort'))) ?>
+ <?php endif; ?>
+ </th>
+ <?php if (!in_array($sf_request->sort, array('nameDown', 'nameUp'))): ?>
+ <th>
+ <?php echo __('Updated') ?>
+ <?php if ('updatedUp' == $sf_request->sort): ?>
+ <?php echo link_to(image_tag('up.gif'), array('sort' =>
'updatedDown') + $sf_request->getParameterHolder()->getAll(), array('title' =>
__('Sort'))) ?>
+ <?php else: ?>
+ <?php echo link_to(image_tag('down.gif'), array('sort' =>
'updatedUp') + $sf_request->getParameterHolder()->getAll(), array('title' =>
__('Sort'))) ?>
+ <?php endif; ?>
+ </th>
+ <?php endif; ?>
+ </tr>
+ </thead><tbody>
+ <?php foreach ($pager->getResults() as $item): ?>
+ <tr class="<?php echo 0 == ++$row % 2 ? 'even' : 'odd' ?>">
+ <td>
+ <?php echo link_to(render_title($item), array($item, 'module' =>
'donor')) ?>
+ </td>
+ <?php if (!in_array($sf_request->sort, array('nameDown', 'nameUp'))):
?>
+ <td>
+ <?php echo format_date($item->updatedAt, 'f') ?>
+ </td>
+ <?php endif; ?>
+ </tr>
+ <?php endforeach; ?>
+ </tbody>
+</table>
+
+<?php echo get_partial('default/pager', array('pager' => $pager)) ?>
+
+<div class="search">
+ <form action="<?php echo url_for(array('module' => 'donor', 'action' =>
'list')) ?>">
+ <input name="subquery" value="<?php echo
esc_entities($sf_request->subquery) ?>"/>
+ <input class="form-submit" type="submit" value="<?php echo __('Search
donor') ?>"/>
+ </form>
+</div>
Added: trunk/plugins/qtAccessionPlugin/modules/donor/templates/deleteSuccess.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/plugins/qtAccessionPlugin/modules/donor/templates/deleteSuccess.php
Mon Jul 11 20:19:55 2011 (r9281)
@@ -0,0 +1,18 @@
+<h1><?php echo __('Are you sure you want to delete %1%?', array('%1%' =>
render_title($resource))) ?></h1>
+
+<?php echo $form->renderFormTag(url_for(array($resource, 'module' => 'donor',
'action' => 'delete')), array('method' => 'delete')) ?>
+
+ <div class="actions section">
+
+ <h2 class="element-invisible"><?php echo __('Actions') ?></h2>
+
+ <div class="content">
+ <ul class="clearfix links">
+ <li><?php echo link_to(__('Cancel'), array($resource, 'module' =>
'donor')) ?></li>
+ <li><input class="form-submit" type="submit" value="<?php echo
__('Confirm') ?>"/></li>
+ </ul>
+ </div>
+
+ </div>
+
+</form>
Modified:
trunk/plugins/qtAccessionPlugin/modules/donor/templates/listSuccess.php
==============================================================================
--- trunk/plugins/qtAccessionPlugin/modules/donor/templates/listSuccess.php
Mon Jul 11 19:06:53 2011 (r9280)
+++ trunk/plugins/qtAccessionPlugin/modules/donor/templates/listSuccess.php
Mon Jul 11 20:19:55 2011 (r9281)
@@ -1,4 +1,4 @@
-<h1><?php echo __('Search %1%', array('%1%' =>
sfConfig::get('app_ui_label_donor'))) ?></h1>
+<h1><?php echo __('List donor') ?></h1>
<?php if (isset($error)): ?>
@@ -21,7 +21,7 @@
<?php foreach ($donors as $item): ?>
<tr class="<?php echo 0 == ++$row % 2 ? 'even' : 'odd' ?>">
<td>
- <?php echo link_to(render_title($item), $item) ?>
+ <?php echo link_to(render_title($item), array($item, 'module' =>
'donor')) ?>
</td>
</tr>
<?php endforeach; ?>
@@ -31,3 +31,10 @@
<?php echo get_partial('default/pager', array('pager' => $pager)) ?>
<?php endif; ?>
+
+<div class="search">
+ <form action="<?php echo url_for(array('module' => 'donor', 'action' =>
'list')) ?>">
+ <input name="subquery" value="<?php echo
esc_entities($sf_request->subquery) ?>"/>
+ <input class="form-submit" type="submit" value="<?php echo __('Search
donor') ?>"/>
+ </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.