Author: sevein
Date: Tue Jul 12 10:16:42 2011
New Revision: 9291
Log:
Accession browser
Added:
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/actions/browseAction.class.php
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/browseSuccess.php
Added:
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/actions/browseAction.class.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/actions/browseAction.class.php
Tue Jul 12 10:16:42 2011 (r9291)
@@ -0,0 +1,75 @@
+<?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 qtAccessionPluginBrowseAction extends sfAction
+{
+ public function execute($request)
+ {
+ if (!$this->context->user->hasCredential(array('contributor', 'editor',
'administrator'), false))
+ {
+ QubitAcl::forwardUnauthorized();
+ }
+
+ if (!isset($request->limit))
+ {
+ $request->limit = sfConfig::get('app_hits_per_page');
+ }
+
+ $criteria = new Criteria;
+
+ switch ($request->sort)
+ {
+ case 'nameDown':
+ $criteria->addDescendingOrderByColumn('identifier');
+
+ break;
+
+ case 'nameUp':
+ $criteria->addAscendingOrderByColumn('identifier');
+
+ 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('QubitAccession');
+ $this->pager->setCriteria($criteria);
+ $this->pager->setMaxPerPage($request->limit);
+ $this->pager->setPage($request->page);
+ }
+}
Added:
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/browseSuccess.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/browseSuccess.php
Tue Jul 12 10:16:42 2011 (r9291)
@@ -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>
--
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.