<table width="100%" cellspacing="0">
 <tr class="item">
  <th class="<?php echo ($sortby == NAG_SORT_COMPLETION) ? 'selected' : 'item' ?>" width="2%" align="left" nowrap="nowrap">
    <?php if ($sortby == NAG_SORT_COMPLETION) echo Horde::link(Horde::applicationUrl(Util::addParameter($sortbyurl, 'sortby', NAG_SORT_COMPLETION)), _("Change sort direction"), 'widget') . Horde::img($sortdir ? 'za.png' :  'az.png', _("Change sort direction"), null, $registry->getImageDir('horde')) ?></a>
    <?php echo Horde::link(Horde::applicationUrl(Util::addParameter($baseurl, 'sortby', NAG_SORT_COMPLETION)), _("Sort by Completion Status"), 'widget') . Horde::img('checkbox.png', _("Completed?")) ?></a>
  </th>
<?php if ($showTasklist): ?>
  <th class="<?php echo ($sortby == NAG_SORT_OWNER) ? 'selected' : 'item' ?>" width="2%" align="left" nowrap="nowrap">
    <?php if ($sortby == NAG_SORT_OWNER) echo Horde::link(Horde::applicationUrl(Util::addParameter($sortbyurl, 'sortby', NAG_SORT_OWNER)), _("Change sort direction"), 'widget') . Horde::img($sortdir ? 'za.png' :  'az.png', _("Change sort direction"), null, $registry->getImageDir('horde')) ?></a>
    <?php echo Horde::widget(Horde::applicationUrl(Util::addParameter($baseurl, 'sortby', NAG_SORT_OWNER)), _("Sort by User Name"), 'widget', '', '', _("_Task List")) ?>&nbsp;
  </th>
<?php endif; ?>
  <th class="<?php echo ($sortby == NAG_SORT_PRIORITY) ? 'selected' : 'item' ?>" width="2%" align="left" nowrap="nowrap">
    <?php if ($sortby == NAG_SORT_PRIORITY) echo Horde::link(Horde::applicationUrl(Util::addParameter($sortbyurl, 'sortby', NAG_SORT_PRIORITY)), _("Change sort direction"), 'widget') . Horde::img($sortdir ? 'za.png' : 'az.png', _("Change sort direction"), null, $registry->getImageDir('horde')) ?></a>
    <?php echo Horde::widget(Horde::applicationUrl(Util::addParameter($baseurl, 'sortby', NAG_SORT_PRIORITY)), _("Sort by Priority"), 'widget', '', '', _("P_ri")) ?>&nbsp;
  </th>
  <th width="2%">
    <?php echo Horde::img('edit.png', _("Edit Task"), null, $registry->getImageDir('horde')) ?>
  </td>
  <th class="<?php echo ($sortby == NAG_SORT_NAME) ? 'selected' : 'item' ?>" width="60%" align="left" nowrap="nowrap">
    <?php if ($sortby == NAG_SORT_NAME) echo Horde::link(Horde::applicationUrl(Util::addParameter($sortbyurl, 'sortby', NAG_SORT_NAME)), _("Change sort direction"), 'widget') . Horde::img($sortdir ? 'za.png' : 'az.png', _("Change sort direction"), null, $registry->getImageDir('horde')) ?></a>
    <?php echo Horde::widget(Horde::applicationUrl(Util::addParameter($baseurl, 'sortby', NAG_SORT_NAME)), _("Sort by Name"), 'widget', '', '', _("Na_me")) ?>&nbsp;
  </th>
  <td width="2%"><?php echo Horde::img('note.png', _("Task Note?")) ?></td>
  <td width="2%"><?php echo Horde::img('alarm.png', _("Task Alarm?")) ?></td>
  <th class="<?php echo ($sortby == NAG_SORT_DUE) ? 'selected' : 'item' ?>" width="12%" align="left" nowrap="nowrap">
    <?php if ($sortby == NAG_SORT_DUE) echo Horde::link(Horde::applicationUrl(Util::addParameter($sortbyurl, 'sortby', NAG_SORT_DUE)), _("Change sort direction"), 'widget') . Horde::img($sortdir ? 'za.png' : 'az.png', _("Change sort direction"), null, $registry->getImageDir('horde')) ?></a>
    <?php echo Horde::widget(Horde::applicationUrl(Util::addParameter($baseurl, 'sortby', NAG_SORT_DUE)), _("Sort by Due Date"), 'widget', '', '', _("_Due Date")) ?>&nbsp;
  </th>
  <th class="<?php echo ($sortby == NAG_SORT_CATEGORY) ? 'selected' : 'item' ?>" width="20%" align="left" nowrap="nowrap">
    <?php if ($sortby == NAG_SORT_CATEGORY) echo Horde::link(Horde::applicationUrl(Util::addParameter($sortbyurl, 'sortby', NAG_SORT_CATEGORY)), _("Change sort direction"), 'widget') . Horde::img($sortdir ? 'za.png' : 'az.png', _("Change sort direction"), null, $registry->getImageDir('horde')) ?></a>
    <?php echo Horde::widget(Horde::applicationUrl(Util::addParameter($baseurl, 'sortby', NAG_SORT_CATEGORY)), _("Sort by Category"), 'widget', '', '', _("Cat_egory")) ?>&nbsp;
    <?php
    if (Auth::getAuth() && (!$GLOBALS['prefs']->isLocked('categories') ||
                            !$GLOBALS['prefs']->isLocked('category_colors'))) {
        $categoryUrl = Util::addParameter(Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/prefs.php'), array('app' => 'horde', 'group' => 'categories'));
        echo ' ' . Horde::link($categoryUrl, _("Edit categories and colors"), 'widget', '_blank') . Horde::img('colorpicker.png', _("Edit categories and colors"), array('align' => 'absmiddle'), $GLOBALS['registry']->getImageDir('horde')) . '</a>';
    }
    ?>
  </th>
 </tr>
