Author: sevein
Date: Mon Jun 11 15:39:09 2012
New Revision: 11760
Log:
Most of the server code for the treeview done now, showing title, show all
button works properly now along with ancestors links, etc...
Modified:
branches/2.0/apps/qubit/modules/informationobject/actions/treeViewAction.class.php
branches/2.0/apps/qubit/modules/informationobject/actions/treeViewComponent.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
Mon Jun 11 15:37:05 2012 (r11759)
+++
branches/2.0/apps/qubit/modules/informationobject/actions/treeViewAction.class.php
Mon Jun 11 15:39:09 2012 (r11760)
@@ -23,99 +23,76 @@
public function execute($request)
{
- $this->resource = $this->getRoute()->resource;
+ if (isset($this->getRoute()->resource))
+ {
+ $this->resource = $this->getRoute()->resource;
+ }
+ else
+ {
+ $this->resource = QubitInformationObject::getRoot();
+ }
+
+ $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 = ?';
switch ($request->show)
{
case 'all':
-
- $this->items = $this->getAll();
-
- break;
-
case 'item':
+ default:
- $this->items = $this->getItem();
+ $sql .= '
+ ORDER BY io.lft ASC
+ LIMIT '.self::SIBLINGS;
+
+ $this->items = QubitPdo::fetchAll($sql, array(
+ $this->resource->id,
+ $this->context->user->getCulture()));
break;
case 'nextSiblings':
- $this->items = $this->getNextSiblings();
+ $sql .= '
+ AND io.lft > ?
+ ORDER BY io.lft ASC
+ LIMIT '.self::SIBLINGS;
+
+ $this->items = QubitPdo::fetchAll($sql, array(
+ $this->resource->parentId,
+ $this->context->user->getCulture(),
+ $this->resource->lft));
break;
case 'prevSiblings':
- $this->items = $this->getPrevSiblings();
+ $sql .= '
+ AND io.lft < ?
+ ORDER BY io.lft DESC
+ LIMIT '.self::SIBLINGS;
+
+ // Notice usage of array_reverse to invert the order
+ $this->items = array_reverse(
+ QubitPdo::fetchAll($sql, array(
+ $this->resource->parentId,
+ $this->context->user->getCulture(),
+ $this->resource->lft)));
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/actions/treeViewComponent.class.php
==============================================================================
---
branches/2.0/apps/qubit/modules/informationobject/actions/treeViewComponent.class.php
Mon Jun 11 15:37:05 2012 (r11759)
+++
branches/2.0/apps/qubit/modules/informationobject/actions/treeViewComponent.class.php
Mon Jun 11 15:39:09 2012 (r11760)
@@ -109,16 +109,6 @@
$prevSiblingsCount = count($this->treeview['prevSiblings']);
$nextSiblingsCount = count($this->treeview['nextSiblings']);
- function array_cut($operation, &$array, $iterate)
- {
- while (($iterate--) != false)
- {
- call_user_func_array("array_$operation", array(&$array));
- }
-
- return $array;
- }
-
// Half part of total of siblings to be shown
$half = floor(self::SIBLINGS / 2);
@@ -166,6 +156,16 @@
}
}
+ function array_cut($operation, &$array, $iterate)
+ {
+ while (($iterate--) != false)
+ {
+ call_user_func_array("array_$operation", array(&$array));
+ }
+
+ return $array;
+ }
+
array_cut('shift', $this->treeview['prevSiblings'], $prevSiblingsSlice);
array_cut('pop', $this->treeview['nextSiblings'], $nextSiblingsSlice);
}
Modified:
branches/2.0/apps/qubit/modules/informationobject/templates/_treeView.php
==============================================================================
--- branches/2.0/apps/qubit/modules/informationobject/templates/_treeView.php
Mon Jun 11 15:37:05 2012 (r11759)
+++ branches/2.0/apps/qubit/modules/informationobject/templates/_treeView.php
Mon Jun 11 15:39:09 2012 (r11760)
@@ -1,44 +1,57 @@
-<div class="tab-pane active" id="treeview" data-xhr-location="<?php echo
url_for(array($resource, 'module' => 'informationobject', 'action' =>
'treeView')) ?>">
+<div class="tab-pane active" id="treeview">
<ul class="unstyled">
-
- <li class="back"><i></i><?php echo link_to(__('Show all'), array('module'
=> 'informationobject', 'action' => 'browse')) ?></li>
+ <li class="back" style="<?php echo QubitInformationObject::ROOT_ID ==
$resource->parentId ? 'display: none;' : '' ?>" data-xhr-location="<?php echo
url_for(array('module' => 'informationobject', 'action' => 'treeView')) ?>">
+ <i></i>
+ <?php echo link_to(__('Show all'), array('module' =>
'informationobject', 'action' => 'browse')) ?>
+ </li>
<?php foreach ($treeview['ancestors'] as $item): ?>
- <li class="ancestor"><i></i><?php echo link_to($item->id . '-' .
$item->lft . '-' . $item->rgt, array('module' => 'informationobject', 'slug' =>
$item->slug)) ?> <strong>LOD</strong></li>
+ <li class="ancestor" data-xhr-location="<?php echo
url_for(array('module' => 'informationobject', 'action' => 'treeView', 'slug'
=> $item->slug)) ?>">
+ <i></i>
+ <?php echo link_to($item->title, array('module' =>
'informationobject', 'slug' => $item->slug)) ?>
+ <strong>LOD</strong>
+ </li>
<?php endforeach; ?>
<?php if (isset($treeview['prevSiblings']) && 0 <
count($treeview['prevSiblings'])): ?>
<?php if (1 < $treeview['prevSiblings'][0]->lft - $parent->lft): ?>
- <li class="more" data-xhr-location="<?php echo url_for(array('module'
=> 'informationobject', 'action' => 'treeView', 'slug' =>
$treeview['prevSiblings'][0]->slug)) ?>"><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; ?>
<?php foreach ($treeview['prevSiblings'] as $prev): ?>
<?php $expand = 1 < $prev->rgt - $prev->lft ?>
- <li class="<?php if ($expand) echo 'expand' ?>">
+ <li class="<?php if ($expand) echo 'expand' ?>" data-xhr-location="<?php
echo url_for(array('module' => 'informationobject', 'action' => 'treeView',
'slug' => $prev->slug)) ?>">
<?php if ($expand) echo '<i></i>' ?>
- <?php echo link_to('p' . $prev->id . '-' . $prev->lft . '-' .
$prev->rgt, array('module' => 'informationobject', 'slug' => $prev->slug)) ?>
<strong>LOD</strong>
+ <?php echo link_to($prev->title, array('module' =>
'informationobject', 'slug' => $prev->slug)) ?>
+ <strong>LOD</strong>
</li>
<?php endforeach; ?>
<?php $expand = 1 < $resource->rgt - $resource->lft ?>
- <li class="<?php if ($expand) echo 'expand' ?> active">
+ <li class="<?php if ($expand) echo 'expand' ?> active"
data-xhr-location="<?php echo url_for(array($resource, 'module' =>
'informationobject', 'action' => 'treeView')) ?>">
<?php if ($expand) echo '<i></i>' ?>
- <?php echo link_to($resource->id . '-' . $resource->lft . '-' .
$resource->rgt, array('module' => 'informationobject', 'slug' =>
$resource->slug)) ?> <strong>LOD</strong>
+ <?php echo link_to($resource->title, array($resource, 'module' =>
'informationobject')) ?>
+ <strong>LOD</strong>
</li>
<?php foreach ($treeview['nextSiblings'] as $next): ?>
<?php $expand = 1 < $next->rgt - $next->lft ?>
- <li class="<?php if ($expand) echo 'expand' ?>">
+ <li class="<?php if ($expand) echo 'expand' ?>" data-xhr-location="<?php
echo url_for(array('module' => 'informationobject', 'action' => 'treeView',
'slug' => $next->slug)) ?>">
<?php if ($expand) echo '<i></i>' ?>
- <?php echo link_to('n' . $next->id . '-' . $next->lft . '-' .
$next->rgt, array('module' => 'informationobject', 'slug' => $next->slug)) ?>
<strong>LOD</strong>
+ <?php echo link_to($next->title, array('module' =>
'informationobject', 'slug' => $next->slug)) ?>
+ <strong>LOD</strong>
</li>
<?php endforeach; ?>
<?php $last = isset($next) ? $next : $resource ?>
<?php if ($parent->rgt - $last->rgt > 1): ?>
- <li class="more" data-xhr-location="<?php echo url_for(array('module' =>
'informationobject', 'action' => 'treeView', 'slug' => $last->slug)) ?>"><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
Mon Jun 11 15:37:05 2012 (r11759)
+++
branches/2.0/apps/qubit/modules/informationobject/templates/treeViewSuccess.php
Mon Jun 11 15:39:09 2012 (r11760)
@@ -1,29 +1,24 @@
-<?php if ('all' == $sf_request->show): ?>
-
-
-<?php elseif ('item' == $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 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 else: ?>
+<?php foreach ($items as $item): ?>
+ <?php $expand = 1 < $item->rgt - $item->lft ?>
+ <li class="<?php if ($expand) echo 'expand' ?>" data-xhr-location="<?php
echo url_for(array('module' => 'informationobject', 'action' => 'treeView',
'slug' => $item->slug)) ?>">
+ <?php if ($expand) echo '<i></i>' ?>
+ <?php echo link_to($item->title, array('module' => 'informationobject',
'slug' => $item->slug)) ?> <strong>LOD</strong>
+ </li>
+<?php endforeach; ?>
-<?php var_dump($sf_request->show) ?>
+<?php if (!isset($item->rgt)): ?>
+ <?php echo $item->slug ?>
+<?php endif; ?>
+<?php $parent = $sf_request->show == 'item' || QubitInformationObject::ROOT_ID
== $resource->id ? $resource : $resource->parent ?>
+<?php if ($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; ?>
--
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.