示例#1
0
 public function testSortableHeaderNoSort()
 {
     // No arrow indicator, link sorts ascending
     $this->_consoleUrl->expects($this->once())->method('__invoke')->with(null, null, array('order' => 'Key', 'direction' => 'asc'), true)->will($this->returnValue('ConsoleUrlMock'));
     $this->_htmlTag->expects($this->once())->method('__invoke')->with('a', 'Label', array('href' => 'ConsoleUrlMock'))->will($this->returnValue('HtmlTagMock'));
     $helper = new \Console\View\Helper\Table($this->_escapeHtml, $this->_htmlTag, $this->_consoleUrl, $this->_dateFormat);
     $this->assertEquals('HtmlTagMock', $helper->sortableHeader('Label', 'Key', 'Order', 'desc'));
 }
示例#2
0
 /**
  * Generate a header hyperlink
  *
  * @param string $label Header text. An arrow will be added to the currently sorted column.
  * @param string $key Sort key to be used in the URL
  * @param string $order Current order
  * @param string $direction Current direction
  * @return string HTML Hyperlink
  */
 public function sortableHeader($label, $key, $order, $direction)
 {
     if ($key == $order) {
         // add arrow indicator to currently sorted column and
         // invert direction for the hyperlink.
         if ($direction == 'asc') {
             $linkDirection = 'desc';
             $label .= '↑';
         } else {
             $linkDirection = 'asc';
             $label .= '↓';
         }
     } else {
         // use ascending ordering for every other hyperlink.
         $linkDirection = 'asc';
     }
     $params = array('order' => $key, 'direction' => $linkDirection);
     return $this->_htmlElement->__invoke('a', $label, array('href' => $this->_consoleUrl->__invoke(null, null, $params, true)), true);
 }