示例#1
0
 /**
  * Render Form
  *
  * @param string $caption Any valid HTML code. Calling code must escape content if necessary.
  * @param array $params Optional name/value pairs that will be included as hidden elements.
  * @return string Form code
  */
 public function __invoke($caption, $params = array())
 {
     $hiddenFields = '';
     foreach ($params as $name => $value) {
         $hiddenFields .= $this->_htmlTag->__invoke('input', null, array('type' => 'hidden', 'name' => $name, 'value' => $value));
     }
     return sprintf("<div class='form_yesno'>\n" . "<p>%s</p>\n" . "<form action='' method='POST'>\n" . "<p>\n%s<input type='submit' name='yes' value='%s'>&nbsp;\n" . "<input type='submit' name='no' value='%s'>\n</p>\n" . "</form>\n</div>\n", $caption, $hiddenFields, $this->_translate->__invoke('Yes'), $this->_translate->__invoke('No'));
 }
示例#2
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'));
 }
示例#3
0
 /**
  * Generate a table row
  * 
  * @param array $columns Column data
  * @param bool $isHeader Use "th" tag instead of "td". Default: false
  * @param string[] $columnClasses Optional class attributes to apply to cells (keys are matched against $row)
  * @param string $rowClass Optional class attribute for the row
  * @return string HTML table row
  */
 public function row(array $columns, $isHeader = false, $columnClasses = array(), $rowClass = null)
 {
     $row = '';
     foreach ($columns as $key => $column) {
         $row .= $this->_htmlTag->__invoke($isHeader ? 'th' : 'td', $column, isset($columnClasses[$key]) ? array('class' => $columnClasses[$key]) : null);
     }
     return $this->_htmlTag->__invoke('tr', $row, $rowClass ? array('class' => $rowClass) : null);
 }
 /**
  * Translate and format messages with sprintf()-style placeholders
  *
  * This helper takes a list of items and returns a list of translated and
  * formatted messages. Each item can be a simple string which will just be
  * translated, or an associative array. Only the first element of an array
  * item is evaluated. The key is a message string with sprintf()-style
  * placeholders that will be translated and then be fed with the array
  * value, which must be an array of arguments. If only 1 argument is
  * required, it can be passed directly.
  *
  * Example:
  *
  *     $input = array(
  *         'message1',
  *         array('message2 %s' => 'arg'),
  *         array('message3 %s %s' => array('arg1', 'arg2'))
  *     );
  *     $output = array(
  *         'translated1',
  *         'translated2 arg',
  *         'translated3 arg1 arg2'
  *     );
  *
  * All strings and arguments get escaped. \Zend\Uri\Http arguments are
  * converted to hyperlinks.
  *
  * @param mixed[] $messages
  * @return string[]
  */
 public function __invoke(array $messages)
 {
     foreach ($messages as &$message) {
         if (is_array($message)) {
             $format = key($message);
             $args = current($message);
             if (!is_array($args)) {
                 $args = array($args);
             }
             foreach ($args as &$arg) {
                 if ($arg instanceof \Zend\Uri\Http) {
                     $arg = $this->_htmlTag->__invoke('a', $this->_escapeHtml->__invoke($arg), array('href' => $arg), true);
                 } else {
                     $arg = $this->_escapeHtml->__invoke($arg);
                 }
             }
             $message = vsprintf($this->_translate->__invoke($format), $args);
         } else {
             $message = $this->_translate->__invoke($message);
         }
     }
     return $messages;
 }