예제 #1
0
파일: Twitter.php 프로젝트: schpill/thin
 /**
  * Renders the image tag
  *
  * @param string $src
  * @param array $attributes
  *
  * @return string
  */
 protected static function _renderImage($src, $className, array $attributes = array())
 {
     if (is_array($attributes['class'])) {
         $attributes['class'][] = $className;
     } else {
         $attributes['class'] .= ' ' . $className;
     }
     return sprintf('<img src="%s"%s />', Html::escape($src), Html::attributes($attributes));
 }
예제 #2
0
파일: Row.php 프로젝트: schpill/thin
 /**
  * Generates a string representation of the table row
  *
  * @return string
  */
 public function __toString()
 {
     $content = '';
     foreach ($this as $cell) {
         $content .= $cell;
     }
     $attributes = $this->getAttributes() ?: array();
     if (null !== $this->_state) {
         if (!isset($attributes['class'])) {
             $attributes['class'] = array();
         }
         $attributes['class'][] = $this->_state;
     }
     return sprintf('<tr%s>%s</tr>', Html::attributes($attributes), $content);
 }
예제 #3
0
파일: Cell.php 프로젝트: schpill/thin
 /**
  * Renders the table cell
  *
  * @return string
  */
 public function __toString()
 {
     $tag = 't' . ($this->_isHeader ? 'h' : 'd');
     return sprintf('<%s%s>%s</%s>', $tag, Html::attributes($this->getAttributes()), Html::escape($this->getValue()), $tag);
 }
예제 #4
0
파일: Table.php 프로젝트: schpill/thin
 /**
  * Renders the table element
  *
  * @return string
  */
 public function __toString()
 {
     $attributes = $this->_attributes;
     if (!isset($attributes['class'])) {
         $attributes['class'] = array();
     }
     if (!in_array('table', $attributes['class'])) {
         $attributes['class'][] = 'table';
     }
     foreach (array('stripped', 'bordered', 'hover', 'condensed') as $attribute) {
         $method = 'is' . ucfirst($attribute);
         $className = 'table-' . $attribute;
         if ($this->{$method}() && !in_array($className, $attributes['class'])) {
             $attributes['class'][] = $className;
         }
     }
     $content = '';
     if (null !== $this->_caption) {
         $content .= sprintf('<caption>%s</caption>', Html::escape($this->_caption));
     }
     if (null !== $this->_header) {
         $content .= sprintf('<thead>%s</thead>', $this->_header);
     }
     $rowsAsString = '';
     if (count($this->_rows)) {
         foreach ($this->_rows as $row) {
             $rowsAsString .= $row;
         }
         $content .= sprintf('<tbody>%s</tbody>', $rowsAsString);
     }
     return sprintf('<table%s>%s</table>', Html::attributes($attributes), $content);
 }