<?php if (empty($userSet)): ?>
<th><?php __('User Name');?></th>
<?php endif; ?>
+ <th class="Notes"><?php __('Notes');?></th>
<th><?php __('Modified');?></th>
</tr>
<?php
</td>
<?php endif; ?>
<td>
+ <?php echo $profiledisp->multi_truncate($character['Character']['notes']); ?>
+</td>
+<td>
<?php echo $time->niceShort($character['Character']['modified'], array('format' => 'Y/m/d H:i')); ?>
</td>
</tr>
return $this->Html->tag('tr', $tds, $tr_options);
}
+
+ /* 一定の文字数で複数行に折り返すtruncate
+ * マルチバイト対応
+ * URLやタグはスキップしない
+ * @param array $options is for truncate()
+ */
+ function multi_truncate($text, $length = 20, $rows = 3, $options = array())
+ {
+ if (empty($text)) {
+ return $text;
+ }
+
+ $rows = (int)$rows;
+ if (!($rows > 0)) {
+ $rows = 1;
+ }
+
+ // 置換
+ $replace_pairs = array(
+ // 改行
+ '<br>' => "\n",
+ '<br />' => "\n",
+ // スペースの連続
+ "\s\s" => "\s",
+ ' ' => '',
+ );
+ $text = strtr($text, $replace_pairs);
+
+ // Sanitize戻し
+ $Sanitize = CorePlus::set_behavoir('SanitizePlus');
+ $text = $Sanitize->restore_html($this->model(), $text);
+
+ $text = trim($text);
+
+ if (mb_strlen($text) < $length) {
+ return $text;
+ }
+
+ // 複数行対応
+ $result = array();
+ $last_row = '';
+ for ($i = 1; $i <= $rows; $i++) {
+ if ($i > 1) {
+ if (!$text) {
+ break;
+ }
+
+ // 前行の分を切り取り
+ if (!empty($last_row)) {
+ $text = substr_replace($text, '', 0, strlen($last_row));
+ }
+ }
+ if ($i == $rows) {
+ $text_len = mb_strlen($text);
+
+ if ($text_len < $length) {
+ $result[$i] = $text;
+ } else {
+ $result[$i] = $this->Text->truncate($text, mb_strlen(mb_substr($text, 0, $length)), $options);
+ }
+
+ break;
+ } else {
+ $result[$i] = mb_substr($text, 0, $length);
+ }
+
+ $last_row = $result[$i];
+ $result[$i] = strip_tags($result[$i]);
+
+
+ // タグをエスケープ
+ $result[$i] = $Sanitize->escapeTags($this->model(), $result[$i]);
+ }
+
+ $text = implode("<br />\n", $result);
+
+ return $text;
+ }
+
+
}