PHP Class BlogHelper

User: powellc Date: 7/29/12 Time: 10:13 PM To change this template use File | Settings | File Templates.
Datei anzeigen Open project: baserproject/basercms Class Usage Examples

Public Properties

Property Type Description
$BlogCategory BlogCategory ブログカテゴリモデル
$helpers array ヘルパー

Public Methods

Method Description
__construct ( View $View, array $settings = [] ) : void コンストラクタ
allowPublish ( array $data ) : boolean 公開状態を取得する
author ( array $post ) : void 記事の投稿者を出力する
blogName ( ) : void ブログアカウント名を出力する
category ( array $post, array $options = [] ) : void 記事が属するカテゴリ名を出力する
currentBlogId ( ) : void ブログIDを出力する
description ( ) : void ブログの説明文を出力する
descriptionExists ( ) : boolean ブログの説明文が指定されているかどうかを判定する
eyeCatch ( array $post, array $options = [] ) : void アイキャッチ画像を出力する
getBlogArchiveType ( ) : string ブログのアーカイブタイプを取得する
getBlogName ( ) : string ブログアカウント名を取得する
getBlogTemplates ( $siteId ) : array ブログテンプレートを取得
getCategory ( array $post, array $options = [] ) : string 記事が属するカテゴリ名を取得する
getCategoryList ( array $categories, integer $depth = 3, boolean $count = false, array $options = [] ) : string カテゴリーの一覧をリストタグで取得する
getCategoryUrl ( $blogCategoryId, array $options = [] ) : string カテゴリ一覧へのURLを取得する
getCurrentBlogId ( ) : integer ブログIDを取得する
getDescription ( ) : string ブログの説明文を取得する
getEyeCatch ( array $post, array $options = [] ) : string アイキャッチ画像を取得する
getHtmlById ( array $post, string $id ) : string 記事中のタグで指定したIDの内容を取得する
getParentCategory ( array $post ) : array 親カテゴリを取得する
getPostContent ( array $post, boolean $moreText = true, mixied $moreLink = false, mixed $cut = false ) : string 記事の本文を取得する
getPostDate ( array $post, string $format = 'Y/m/d' ) : string 登録日
getPostDetail ( array $post, array $options = [] ) : string 記事の詳細を取得する
getPostImg ( array $post, array $options = [] ) : string 記事中の画像を取得する
getPostLink ( array $post, string $title, array $options = [] ) : string 記事へのリンクを取得する
getPostLinkUrl ( array $post ) : string ブログ記事のURLを取得する
getPostTitle ( array $post, boolean $link = true ) : string 記事タイトルを取得する
getRelatedPosts ( array $post, array $options = [] ) : array 同じタグの関連投稿を取得する
getTag ( array $post, string $separator = ' , ' ) : void タグを取得する
getTitle ( ) : string タイトルを取得する
isArchive ( ) : boolean アーカイブページ判定
isCategory ( ) : boolean カテゴリー別記事一覧ページ判定
isDate ( ) : boolean 日別記事一覧ページ判定
isHome ( ) : boolean インデックスページ判定
isMonth ( ) : boolean 月別記事一覧ページ判定
isSingle ( ) : boolean 個別ページ判定
isTag ( ) : boolean タグ別記事一覧ページ判定
isYear ( ) : boolean 年別記事一覧ページ判定
mailFormLink ( string $title, string $contentsName, array $datas = [], array $options = [] ) : void メールフォームプラグインのフォームへのリンクを生成する
nextLink ( array $post, string $title = '', array $htmlAttributes = [] ) : void 次の記事へのリンクを出力する
postContent ( array $post, boolean $moreText = true, mixied $moreLink = false, mixed $cut = false ) : void 記事の本文を表示する
postDate ( array $post, string $format = 'Y/m/d' ) : void 記事の登録日を出力する
postDetail ( array $post, array $options = [] ) : void 記事の詳細を表示する
postImg ( array $post, array $options = [] ) : void 記事中の画像を出力する
postLink ( array $post, string $title, array $options = [] ) : void 記事へのリンクを出力する
postTitle ( array $post, boolean $link = true ) : void 記事のタイトルを出力する
prevLink ( array $post, string $title = '', array $htmlAttributes = [] ) : void 前の記事へのリンクを出力する
removeCtrlChars ( $string ) 文字列から制御文字を取り除く
setContent ( integer $blogContentId = null ) : void ブログコンテンツデータをセットする
tag ( array $post, string $separator = ' , ' ) : void タグを出力する
title ( ) : void ブログタイトルを出力する

Protected Methods

Method Description
_getCategoryList ( array $categories, integer $depth = 3, integer $current = 1, boolean $count = false, array $options = [] ) : string カテゴリーリストを取得する

Method Details

__construct() public method

コンストラクタ
public __construct ( View $View, array $settings = [] ) : void
$View View Viewオブジェクト
$settings array 設定
return void

_getCategoryList() protected method

カテゴリーリストを取得する
protected _getCategoryList ( array $categories, integer $depth = 3, integer $current = 1, boolean $count = false, array $options = [] ) : string
$categories array カテゴリ一覧データ
$depth integer 階層(初期値 : 3)
$current integer 現在の階層(初期値 : 1)
$count boolean 件数を表示するかどうか(初期値 : false)
$options array オプション(初期値 : array()) - `link` : リンクをつけるかどうか(初期値 : true) ※ その他のオプションは、`link`オプションが`true`の場合に 生成されるa要素の属性設定となる。(HtmlHelper::link() を参照)
return string HTMLのカテゴリ一覧

allowPublish() public method

公開状態を取得する
public allowPublish ( array $data ) : boolean
$data array ブログ記事
return boolean 公開状態

author() public method

記事の投稿者を出力する
public author ( array $post ) : void
$post array ブログ記事
return void

blogName() public method

ブログアカウント名を出力する
public blogName ( ) : void
return void

category() public method

記事が属するカテゴリ名を出力する
public category ( array $post, array $options = [] ) : void
$post array 記事データ
$options array オプション(初期値 : array()) - `link` : リンクをつけるかどうか(初期値 : true) ※ その他のオプションは、`link`オプションが`true`の場合に 生成されるa要素の属性設定となる。(HtmlHelper::link() を参照)
return void

currentBlogId() public method

ブログIDを出力する
public currentBlogId ( ) : void
return void

description() public method

ブログの説明文を出力する
public description ( ) : void
return void

descriptionExists() public method

ブログの説明文が指定されているかどうかを判定する
public descriptionExists ( ) : boolean
return boolean

eyeCatch() public method

アイキャッチ画像を出力する
public eyeCatch ( array $post, array $options = [] ) : void
$post array ブログ記事
$options array オプション(初期値 : array()) - `imgsize` : 画像サイズ[thumb|small|medium|large](初期値 : thumb) - `link` : 大きいサイズの画像へのリンク有無(初期値 : true) - `escape` : タイトルについてエスケープする場合に true を指定(初期値 : false) - `mobile` : モバイルの画像を表示する場合に true を指定(初期値 : false) - `alt` : alt属性(初期値 : '') - `width` : 横幅(初期値 : '') - `height` : 高さ(初期値 : '') - `noimage` : 画像が存在しない場合に表示する画像(初期値 : '') - `tmp` : 一時保存データの場合に true を指定(初期値 : false) - `class` : タグの class を指定(初期値 : img-eye-catch) - `force` : 画像が存在しない場合でも強制的に出力する場合に true を指定する(初期値 : false) ※ その他のオプションについては、リンクをつける場合、HtmlHelper::link() を参照、つけない場合、Html::image() を参照
return void

getBlogArchiveType() public method

ブログのアーカイブタイプを取得する
public getBlogArchiveType ( ) : string
return string ブログのアーカイブタイプ

getBlogName() public method

ブログアカウント名を取得する
public getBlogName ( ) : string
return string

getBlogTemplates() public method

コンボボックスのソースとして利用
public getBlogTemplates ( $siteId ) : array
return array ブログテンプレート一覧

getCategory() public method

記事が属するカテゴリ名を取得する
public getCategory ( array $post, array $options = [] ) : string
$post array 記事データ
$options array オプション(初期値 : array()) - `link` : リンクをつけるかどうか(初期値 : true) ※ その他のオプションは、`link`オプションが`true`の場合に 生成されるa要素の属性設定となる。(HtmlHelper::link() を参照)
return string カテゴリ名

getCategoryList() public method

カテゴリーの一覧をリストタグで取得する
public getCategoryList ( array $categories, integer $depth = 3, boolean $count = false, array $options = [] ) : string
$categories array カテゴリ一覧データ
$depth integer 階層(初期値 : 3)
$count boolean 件数を表示するかどうか(初期値 : false)
$options array オプション(初期値 : array()) - `link` : リンクをつけるかどうか(初期値 : true) ※ その他のオプションは、`link`オプションが`true`の場合に 生成されるa要素の属性設定となる。(HtmlHelper::link() を参照)
return string HTMLのカテゴリ一覧

getCategoryUrl() public method

[注意] リンク関数でラップする前提の為、ベースURLは考慮されない
public getCategoryUrl ( $blogCategoryId, array $options = [] ) : string
$options array オプション(初期値 : array()) `named` : URLの名前付きパラメーター
return string カテゴリ一覧へのURL

getCurrentBlogId() public method

ブログIDを取得する
public getCurrentBlogId ( ) : integer
return integer

getDescription() public method

ブログの説明文を取得する
public getDescription ( ) : string
return string

getEyeCatch() public method

アイキャッチ画像を取得する
public getEyeCatch ( array $post, array $options = [] ) : string
$post array ブログ記事
$options array オプション(初期値 : array()) - `imgsize` : 画像サイズ[thumb|small|medium|large](初期値 : thumb) - `link` : 大きいサイズの画像へのリンク有無(初期値 : true) - `escape` : タイトルについてエスケープする場合に true を指定(初期値 : false) - `mobile` : モバイルの画像を表示する場合に true を指定(初期値 : false) - `alt` : alt属性(初期値 : '') - `width` : 横幅(初期値 : '') - `height` : 高さ(初期値 : '') - `noimage` : 画像が存在しない場合に表示する画像(初期値 : '') - `tmp` : 一時保存データの場合に true を指定(初期値 : false) - `class` : タグの class を指定(初期値 : img-eye-catch) - `force` : 画像が存在しない場合でも強制的に出力する場合に true を指定する(初期値 : false) - `output` : 出力形式 tag, url のを指定できる(初期値 : '') ※ その他のオプションについては、リンクをつける場合、HtmlHelper::link() を参照、つけない場合、Html::image() を参照
return string アイキャッチ画像のHTML

getHtmlById() public method

記事中のタグで指定したIDの内容を取得する
public getHtmlById ( array $post, string $id ) : string
$post array ブログ記事
$id string 取得したいデータが属しているタグのID属性
return string 指定したIDの内容

getParentCategory() public method

親カテゴリを取得する
public getParentCategory ( array $post ) : array
$post array ブログ記事
return array $parentCategory 親カテゴリ

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 記事本文

getPostDate() public method

登録日
public getPostDate ( array $post, string $format = 'Y/m/d' ) : string
$post array ブログ記事
$format string 日付フォーマット(初期値 : Y/m/d)
return string 登録日

getPostDetail() public method

記事の詳細を取得する
public getPostDetail ( array $post, array $options = [] ) : string
$post array ブログ記事データ
$options array オプション(初期値 : array()) - `cut` : 文字をカットするかどうかを真偽値で指定。カットする場合、文字数を数値で入力(初期値 : false)
return string 記事本文

getPostImg() public method

記事中の画像を取得する
public getPostImg ( array $post, array $options = [] ) : string
$post array ブログ記事
$options array オプション(初期値 : array()) - `num` : 何枚目の画像か順番を指定(初期値 : 1) - `link` : 詳細ページへのリンクをつけるかどうか(初期値 : true) - `alt` : ALT属性(初期値 : ブログ記事のタイトル)
return string

getPostLinkUrl() public method

ブログ記事のURLを取得する
public getPostLinkUrl ( array $post ) : string
$post array ブログ記事データ
return string ブログ記事のURL

getPostTitle() public method

記事タイトルを取得する
public getPostTitle ( array $post, boolean $link = true ) : string
$post array ブログ記事データ
$link boolean 詳細ページへのリンクをつける場合には、true を指定する(初期値 : true)
return string 記事タイトル

getRelatedPosts() public method

同じタグの関連投稿を取得する
public getRelatedPosts ( array $post, array $options = [] ) : array
$post array ブログ記事
$options array オプション(初期値 : array()) - `recursive` : 関連データを取得する場合の階層(初期値 : -1) - `limit` : 件数(初期値 : 5) - `order` : 並び順指定(初期値 : BlogPost.posts_date DESC)
return array

getTag() public method

複数所属する場合は複数取得する
public getTag ( array $post, string $separator = ' , ' ) : void
$post array 記事データ
$separator string 区切り文字(初期値 : , )
return void

getTitle() public method

タイトルを取得する
public getTitle ( ) : string
return string

isArchive() public method

アーカイブページ判定
public isArchive ( ) : boolean
return boolean 現在のページがアーカイブページの場合は true を返す

isCategory() public method

カテゴリー別記事一覧ページ判定
public isCategory ( ) : boolean
return boolean 現在のページがカテゴリー別記事一覧ページの場合は true を返す

isDate() public method

日別記事一覧ページ判定
public isDate ( ) : boolean
return boolean 現在のページが日別記事一覧ページの場合は true を返す

isHome() public method

インデックスページ判定
public isHome ( ) : boolean
return boolean 現在のページがインデックスページの場合は true を返す

isMonth() public method

月別記事一覧ページ判定
public isMonth ( ) : boolean
return boolean 現在のページが月別記事一覧ページの場合は true を返す

isSingle() public method

個別ページ判定
public isSingle ( ) : boolean
return boolean 現在のページが個別ページの場合は true を返す

isTag() public method

タグ別記事一覧ページ判定
public isTag ( ) : boolean
return boolean 現在のページがタグ別記事一覧ページの場合は true を返す

isYear() public method

年別記事一覧ページ判定
public isYear ( ) : boolean
return boolean 現在のページが年別記事一覧ページの場合は true を返す

postContent() public method

記事の本文を表示する
public postContent ( array $post, boolean $moreText = true, mixied $moreLink = false, mixed $cut = false ) : void
$post array ブログ記事データ
$moreText boolean 詳細データを表示するかどうか(初期値 : true)
$moreLink mixied 詳細ページへのリンクを表示するかどうか。true に指定した場合、 「≫ 続きを読む」という文字列がリンクとして表示される。(初期値 : false) また、文字列を指定するとその文字列がリンクとなる
$cut mixed 文字をカットするかどうかを真偽値で指定。カットする場合、文字数を数値で入力(初期値 : false)
return void

postDate() public method

記事の登録日を出力する
public postDate ( array $post, string $format = 'Y/m/d' ) : void
$post array ブログ記事
$format string 日付フォーマット(初期値 : Y/m/d)
return void

postDetail() public method

記事の詳細を表示する
public postDetail ( array $post, array $options = [] ) : void
$post array ブログ記事データ
$options array オプション(初期値 : array())getPostDetailを参照
return void

postImg() public method

記事中の画像を出力する
public postImg ( array $post, array $options = [] ) : void
$post array ブログ記事
$options array オプション(初期値 : array()) - `num` : 何枚目の画像か順番を指定(初期値 : 1) - `link` : 詳細ページへのリンクをつけるかどうか(初期値 : true) - `alt` : ALT属性(初期値 : ブログ記事のタイトル)
return void

postTitle() public method

記事のタイトルを出力する
public postTitle ( array $post, boolean $link = true ) : void
$post array ブログ記事データ
$link boolean 詳細ページへのリンクをつける場合には、true を指定する(初期値 : true)
return void

removeCtrlChars() public method

文字列から制御文字を取り除く
public removeCtrlChars ( $string )

setContent() public method

アイキャッチを利用する場合に必ず設定が必要
public setContent ( integer $blogContentId = null ) : void
$blogContentId integer ブログコンテンツID
return void

tag() public method

複数所属する場合は複数出力する
public tag ( array $post, string $separator = ' , ' ) : void
$post array 記事データ
$separator string 区切り文字(初期値 : , )
return void

title() public method

ブログタイトルを出力する
public title ( ) : void
return void

Property Details

$BlogCategory public_oe property

ブログカテゴリモデル
public BlogCategory $BlogCategory
return BlogCategory

$helpers public_oe property

ヘルパー
public array $helpers
return array