Author: sevein
Date: Sat Jun 9 15:41:39 2012
New Revision: 11756
Log:
Server code to attend XHR requests in the treeview
Modified:
branches/2.0/apps/qubit/modules/informationobject/actions/treeViewAction.class.php
branches/2.0/apps/qubit/modules/informationobject/templates/_treeView.php
branches/2.0/apps/qubit/modules/informationobject/templates/treeViewSuccess.php
Modified:
branches/2.0/apps/qubit/modules/informationobject/actions/treeViewAction.class.php
==============================================================================
---
branches/2.0/apps/qubit/modules/informationobject/actions/treeViewAction.class.php
Sat Jun 9 15:40:04 2012 (r11755)
+++
branches/2.0/apps/qubit/modules/informationobject/actions/treeViewAction.class.php
Sat Jun 9 15:41:39 2012 (r11756)
@@ -19,23 +19,103 @@
class InformationObjectTreeViewAction extends sfAction
{
+ const SIBLINGS = 10;
+
public function execute($request)
{
$this->resource = $this->getRoute()->resource;
- $query = new Elastica_Query();
-
- if ('all' == $request->show)
+ switch ($request->show)
{
+ case 'all':
- }
- else if ('item' == $request->show)
- {
+ $this->items = $this->getAll();
- }
- else if ('more' == $request->show)
- {
+ break;
+
+ case 'item':
+
+ $this->items = $this->getItem();
+
+ break;
+
+ case 'nextSiblings':
+
+ $this->items = $this->getNextSiblings();
+
+ break;
+
+ case 'prevSiblings':
+ $this->items = $this->getPrevSiblings();
+
+ break;
}
}
+
+ protected function getAll()
+ {
+ }
+
+ protected function getItem()
+ {
+ }
+
+ protected function getNextSiblings()
+ {
+ // Next N siblings
+ $sql = 'SELECT
+ io.*,
+ i18n.*,
+ slug.slug,
+ pubstat.status_id as publication_status_id
+ FROM '.QubitInformationObject::TABLE_NAME.' io
+ JOIN '.QubitInformationObjectI18n::TABLE_NAME.' i18n
+ ON io.id = i18n.id
+ JOIN '.QubitSlug::TABLE_NAME.' slug
+ ON io.id = slug.object_id
+ JOIN '.QubitStatus::TABLE_NAME.' pubstat
+ ON io.id = pubstat.object_id
+ WHERE
+ io.parent_id = ?
+ AND i18n.culture = ?
+ AND io.lft > ?
+ ORDER BY io.lft ASC
+ LIMIT '.self::SIBLINGS;
+
+ return QubitPdo::fetchAll($sql, array(
+ $this->resource->parentId,
+ $this->context->user->getCulture(),
+ $this->resource->lft));
+ }
+
+ protected function getPrevSiblings()
+ {
+ // Previous N siblings
+ $sql = 'SELECT
+ io.*,
+ i18n.*,
+ slug.slug,
+ pubstat.status_id as publication_status_id
+ FROM '.QubitInformationObject::TABLE_NAME.' io
+ JOIN '.QubitInformationObjectI18n::TABLE_NAME.' i18n
+ ON io.id = i18n.id
+ JOIN '.QubitSlug::TABLE_NAME.' slug
+ ON io.id = slug.object_id
+ JOIN '.QubitStatus::TABLE_NAME.' pubstat
+ ON io.id = pubstat.object_id
+ WHERE
+ io.parent_id = ?
+ AND i18n.culture = ?
+ AND io.lft < ?
+ ORDER BY io.lft DESC
+ LIMIT '.self::SIBLINGS;
+
+ // Notice usage of array_reverse to invert the order
+ return array_reverse(
+ QubitPdo::fetchAll($sql, array(
+ $this->resource->parentId,
+ $this->context->user->getCulture(),
+ $this->resource->lft)));
+ }
}
Modified:
branches/2.0/apps/qubit/modules/informationobject/templates/_treeView.php
==============================================================================
--- branches/2.0/apps/qubit/modules/informationobject/templates/_treeView.php
Sat Jun 9 15:40:04 2012 (r11755)
+++ branches/2.0/apps/qubit/modules/informationobject/templates/_treeView.php
Sat Jun 9 15:41:39 2012 (r11756)
@@ -10,7 +10,7 @@
<?php if (isset($treeview['prevSiblings']) && 0 <
count($treeview['prevSiblings'])): ?>
<?php if (1 < $treeview['prevSiblings'][0]->lft - $parent->lft): ?>
- <li class="more"><a href="#">...</a></li>
+ <li class="more" data-xhr-location="<?php echo url_for(array('module'
=> 'informationobject', 'action' => 'treeView', 'slug' =>
$treeview['prevSiblings'][0]->slug)) ?>"><a href="#">...</a></li>
<?php endif; ?>
<?php endif; ?>
@@ -38,7 +38,7 @@
<?php $last = isset($next) ? $next : $resource ?>
<?php if ($parent->rgt - $last->rgt > 1): ?>
- <li class="more"><a href="#">...</a></li>
+ <li class="more" data-xhr-location="<?php echo url_for(array('module' =>
'informationobject', 'action' => 'treeView', 'slug' => $last->slug)) ?>"><a
href="#">...</a></li>
<?php endif; ?>
</ul>
Modified:
branches/2.0/apps/qubit/modules/informationobject/templates/treeViewSuccess.php
==============================================================================
---
branches/2.0/apps/qubit/modules/informationobject/templates/treeViewSuccess.php
Sat Jun 9 15:40:04 2012 (r11755)
+++
branches/2.0/apps/qubit/modules/informationobject/templates/treeViewSuccess.php
Sat Jun 9 15:41:39 2012 (r11756)
@@ -4,8 +4,26 @@
<?php elseif ('item' == $sf_request->show): ?>
-<?php elseif ('more' == $sf_request->show): ?>
+<?php elseif (in_array($sf_request->show, array('nextSiblings',
'prevSiblings'))): ?>
+ <?php if ('prevSiblings' == $sf_request->show && 0 < count($items) && 1 <
($items[0]->lft - $resource->parent->lft)): ?>
+ <li class="more" data-xhr-location="<?php echo url_for(array('module' =>
'informationobject', 'action' => 'treeView', 'slug' => $items[0]->slug)) ?>"><a
href="#">...</a></li>
+ <?php endif; ?>
+ <?php foreach ($items as $item): ?>
+ <?php $expand = 1 < $item->rgt - $item->lft ?>
+ <li class="<?php if ($expand) echo 'expand' ?>">
+ <?php if ($expand) echo '<i></i>' ?>
+ <?php echo link_to('d'.$item->id . '-' . $item->lft . '-' . $item->rgt,
array('module' => 'informationobject', 'slug' => $item->slug)) ?>
<strong>LOD</strong>
+ </li>
+ <?php endforeach; ?>
+
+ <?php if ('nextSiblings' == $sf_request->show && ($resource->parent->rgt -
$item->rgt) > 1): ?>
+ <li class="more" data-xhr-location="<?php echo url_for(array('module' =>
'informationobject', 'action' => 'treeView', 'slug' => $item->slug)) ?>"><a
href="#">...</a></li>
+ <?php endif; ?>
+
+<?php else: ?>
+
+<?php var_dump($sf_request->show) ?>
<?php endif; ?>
--
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.