BlogHelper::getPostContent PHP Method

getPostContent() public method

記事の本文を取得する
public getPostContent ( array $post, boolean $moreText = true, mixied $moreLink = false, mixed $cut = false ) : string
$post array ブログ記事データ
$moreText boolean 詳細データを表示するかどうか(初期値 : true)
$moreLink mixied 詳細ページへのリンクを表示するかどうか。true に指定した場合、 「≫ 続きを読む」という文字列がリンクとして表示される。(初期値 : false) また、文字列を指定するとその文字列がリンクとなる
$cut mixed 文字をカットするかどうかを真偽値で指定。カットする場合、文字数を数値で入力(初期値 : false)
return string 記事本文
    public function getPostContent($post, $moreText = true, $moreLink = false, $cut = false)
    {
        if ($moreLink === true) {
            $moreLink = '≫ 続きを読む';
        }
        $out = '<div class="post-body">' . $post['BlogPost']['content'] . '</div>';
        if ($moreText && $post['BlogPost']['detail']) {
            $out .= '<div id="post-detail">' . $post['BlogPost']['detail'] . '</div>';
        }
        if ($cut) {
            $out = str_replace(array("\r\n", "\r", "\n"), '', $out);
            $out = html_entity_decode($out, ENT_QUOTES, 'UTF-8');
            $out = mb_substr(strip_tags($out), 0, $cut, 'UTF-8');
        }
        if ($moreLink && trim($post['BlogPost']['detail']) && trim($post['BlogPost']['detail']) != "<br>") {
            if (!isset($this->Html)) {
                App::uses('HtmlHelper', 'View/Helper');
                $this->Html = new HtmlHelper($this->_View);
            }
            $out .= '<p class="more">' . $this->Html->link($moreLink, $this->request->params['Content']['url'] . 'archives/' . $post['BlogPost']['no'] . '#post-detail', null, null, false) . '</p>';
        }
        return $out;
    }