<?php 
    $this->deepLevel = $this->deepLevel - 1;
?>
<?php if (count($this->tree) > 0):?>
<ul class="<?php echo (isset($this->isRoot) && $this->isRoot === true) ? '' : 'jstree-open'; ?>">
    <?php foreach ($this->tree as $key => $page): $this->page = $page;?>
        <li id="page-<?php echo $page->pk ?>"<?php if (isset($this->openedNode[$page->pk]) || (null !== $page->getChildren() && $page->getChildren()->count() > 0)) { if ($page->getLevel() > 3 || (isset($this->isRoot) && $this->isRoot === true)) echo ' class="jstree-open"'; else echo 'class="jstree-closed"';}?>>
            <a href="<?php echo $this->url(array('saving' => null, 'action' => 'edit', 'controller' => $this->controllerName, 'module' => $this->moduleName, 'id' => $page->pk), 'default'); ?>" class="page <?php if (isset($this->publishColumn) && !$page->{$this->publishColumn}): ?>hidden<?php endif ?>">
            <?php echo $page->{$this->titleColumn};?></a>
            <div class="cells">
                <div class="online">
                <?php if (isset($this->publishColumn) && $page->can_be_deleted): ?>
                        <select selected="<?php echo (int) $page->{$this->publishColumn} ?>" class="field-switcher" name="<?php echo $this->publishColumn ?>-<?php echo $page->pk ?>">
                            <option value="0"<?php if ($page->{$this->publishColumn} == '0') echo ' selected="selected"'?>><?php echo $this->translate('Offline'); ?></option>
                            <option value="1"<?php if ($page->{$this->publishColumn} == '1') echo ' selected="selected"'?>><?php echo $this->translate('Online'); ?></option>
                        </select>
                <?php else: ?>
                    &nbsp;
                <?php endif; ?>
                </div>
                <?php if (isset($this->publishDateColumn) && null !== $page->{$this->publishDateColumn}):
                $date = $page->getDateObjectBy($this->publishDateColumn);
                ?>
                    <div class="date"><?php echo $date->get(Zend_Date::DATE_MEDIUM) ?></div>
                <?php else: ?>
                    <div class="date">&nbsp;</div>
                <?php endif; ?>
                <div class="actions">
                    <?php echo $this->partial($this->_selectScript(array(sprintf('/%s/_rowActions.phtml', $this->controllerName), '/mptt/_rowActions.phtml')), $this);?>
                </div>
                <div class="clear"></div>
            </div>
            <?php if (($children = $page->getChildren()) && (isset($this->openedNode[$page->pk]) || ($this->deepLevel > 0))) : ?>
                <?php if ($children->count()): ?>
                    <?php echo $this->partial('mptt/index.json.phtml', array_merge($this->getVars(), array('tree' => $page->getChildren(), 'titleColumn' => $this->titleColumn, 'deepLevel' => $this->deepLevel, 'isRoot' => false, 'openedNode' => $this->openedNode))); ?>
                <?php endif ?>
            <?php endif ?>
        </li>
    <?php endforeach ?>
</ul>
<?php endif;?>
