Author: sevein
Date: Sat Jul 28 09:46:27 2012
New Revision: 12000
Log:
Add helper to render treeview nodes
Modified:
trunk/lib/helper/QubitHelper.php
Modified: trunk/lib/helper/QubitHelper.php
==============================================================================
--- trunk/lib/helper/QubitHelper.php Sat Jul 28 00:02:11 2012 (r11999)
+++ trunk/lib/helper/QubitHelper.php Sat Jul 28 09:46:27 2012 (r12000)
@@ -158,6 +158,62 @@
return round(($val / pow(1024, $i)), 1).' '.$units[$i];
}
+function render_treeview_node($item, array $classes = array(), array $options
= array())
+{
+ // Build array of classes
+ $_classes = array();
+ foreach ($classes as $key => $value)
+ {
+ if ($value)
+ {
+ $_classes[$key] = $key;
+ }
+ }
+
+ // Start HTML list element
+ $node = '<li';
+
+ // Create class attribute from $classes array
+ if (0 < count($_classes))
+ {
+ $node .= ' class="'.implode(' ', $_classes).'"';
+ }
+
+ // Add data-xhr-location if exists
+ if (isset($options['xhr-location']))
+ {
+ $node .= ' data-xhr-location="'.$options['xhr-location'].'"';
+ }
+
+ // Close tag
+ $node .= '>';
+
+ // Add <i> tag if the node is expandable
+ if (isset($_classes['expand']) || isset($_classes['back']) ||
isset($_classes['ancestor']))
+ {
+ $node .= '<i></i> ';
+ }
+
+ if (isset($_classes['more']))
+ {
+ $node .= '<a href="#">...</a>';
+ }
+ else
+ {
+ // Add link
+ $node .= link_to($item->title, array('module' => 'informationobject',
'slug' => $item->slug));
+
+ // Level of description
+ $levelOfDescriptionId = $item instanceof QubitObject ?
$item->levelOfDescriptionId : $item->level_of_description_id;
+ $node .=
'<strong>'.QubitTerm::getById($levelOfDescriptionId)->getName().'</strong>';
+ }
+
+ // Close node tag
+ $node .= '</li>';
+
+ return $node;
+}
+
function check_field_visibility($fieldName)
{
return sfContext::getInstance()->user->isAuthenticated() ||
sfConfig::get($fieldName, false);
--
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.