| // +---------------------------------------------------------------------------+ // $Id$ /** * Generates HTML containing data from sections table. * * @package navigation * @author Andy Crain * @author Demian Turner * @author AJ Tarachanowicz * @author Andrey Podshivalov */ class SimpleRenderer { function SimpleRenderer(&$navDriver) { SGL::logMessage(null, PEAR_LOG_DEBUG); $this->driver = &$navDriver; } /** * Returns HTML unordered list with subsections nested; can be used with CSS for navigation * tabs. Adds attribute class="current" to
  • tags. * * @access public * @param array $sectionNodes array of DataObjects_Section objects * @param int $currentRenderedLevel * @return string | false */ function toHtml(&$aSectionNodes, $currentRenderedLevel = 0) { $listItems = ''; $currentRenderedLevel++; foreach ($aSectionNodes as $section) { if ($section->is_enabled) { $liAtts = ''; if ($section->isCurrent || $section->childIsCurrent) { $liAtts = ' class="current"'; } if (isset($section->uriExternal) && empty($section->uriAlias)) { $url = $section->resource_uri; } elseif (isset($section->uriEmpty)) { $url = 'javascript:void(0)'; } else { $url = $this->driver->makeLinkFromSection($section); } $accessKey = !empty($section->access_key) ? ' accesskey="' . $section->access_key . '"' : ''; $anchor = '' . $section->title . ''; $listItems .= "' . $anchor; // show children nodes if ($section->children // check levelsToRender stuff && (!$this->driver->_levelsToRender || $this->driver->_levelsToRender > $currentRenderedLevel) // check collapsed stuff && (!$this->driver->_collapsed || array_key_exists($section->section_id, $this->driver->_aAllCurrentPages))) { $listItems .= $this->toHtml($section->children, $currentRenderedLevel); } $listItems .= "
  • \n"; } } $output = ($listItems) ? "\n
      " . $listItems . "
    \n" : false; return $output; } } ?>