\BEAR_View_Adapter_Smarty

Smartyビューアダプター

BEARフレームワークで使われる基底クラスです。

BEARのクラスはBEAR::factoryやBEAR::dependency()によって以下の順でインスタンス化されます。

1) コンストラクタで設定を行う 2) 設定に基づいてインジェクタで必要なサービスをプロパティに用意

Summary

Methods
Properties
Constants
__construct()
onInject()
setConfig()
getConfig()
setService()
onInjectUaSniffing()
set()
display()
fetch()
No public properties found
No constants found
_getViewInfo()
_getRo()
_agentFilter()
_getRoleFile()
_exception()
$_emoji
$_config
$_smarty
$_log
$_values
N/A
_getRoleLayoutValue()
_getTemplateNameByPageClass()
_removeExtention()
onPackEmoji()
$_role
$_enableJs
N/A

Properties

$_config

$_config : array

Class config

Type

array

$_smarty

$_smarty : \Smarty

Type

\Smarty

$_values

$_values : array

ページバリュー

Type

array

$_role

$_role : array

エージェントロール

Type

array

$_enableJs

$_enableJs : boolean

JS有効スイッチ

Type

boolean

Methods

__construct()

__construct(array  $config) 

Universal constructor

設定を_configプロパティに代入します。

Parameters

array $config

ユーザー設定値

onInject()

onInject() : void

Inject

setConfig()

setConfig(mixed  $config, mixed  $values = null) : self

Set config

Parameters

mixed $config

(string) 設定キー | (array) 設定配列

mixed $values

(string) $configの時の設定値

Returns

self

getConfig()

getConfig(string  $key = null) : mixed

Get config

Parameters

string $key

設定キー、指定なければ全ての設定を取得

Returns

mixed

setService()

setService(string  $name, mixed  $service) : void

Set service

Parameters

string $name

サービスキー

mixed $service

サービス

onInjectUaSniffing()

onInjectUaSniffing() : void

UAスニッフィングインジェクト

UAスニッフィングOnの時のインジェクタです。BEAR_Viewで指定していされています。

set()

set(array  $values) : void

ビューに値をセット

Parameters

array $values

ビューにセットする値

display()

display(string  $tplName = null, array  $options = array()) : \BEAR_Ro

表示

ビューにセットされたバリューをテンプレートに適用して画面表示するHTTPボディとHTTPヘッダーを返します

Parameters

string $tplName

テンプレート名

array $options

オプション

Returns

\BEAR_Ro

fetch()

fetch(string  $tplName) : string

ビュー文字列取得

アサイン済みテンプレートのHTMLを文字列として取得します。

Parameters

string $tplName

テンプレート名

Returns

string

_getViewInfo()

_getViewInfo(string  $tplName = null, array  $role = array(),   $ext = 'tpl') : array

テンプレート名の取得

Parameters

string $tplName

テンプレート名(省略可)

array $role

エージェントロール

$ext

$ext 拡張子

Returns

array

_getRo()

_getRo(string  $html) : \BEAR_ro

リソースオブジェクトに変換

$htmlを受け取りエージェント依存のヘッダーを付加してリソースオブジェクトにして返します。
返されたリソースオブジェクトはoutputHttp()メソッドでHTTP出力ができます。

Parameters

string $html

HTML 文字列

Returns

\BEAR_ro

_agentFilter()

_agentFilter(string  $html) : string

絵文字用アオウトプットフィルター

絵文字を画像表示します。ネイティブ表示できる場合はそちらを優先します。

Parameters

string $html

HTML

Returns

string

_getRoleFile()

_getRoleFile(array  $role, string  $dir, string  $fileName, string  $ext = 'tpl') : string

エージェントロールに対応したファイルを取得

配列でロールに応じたファイルを返します

ex)
roleが'Docomo'の場合

index.docomo.html
index.mobile.html
index.html

というファイルに順にスキャンしてあればそれが使われます。

                                    

Parameters

array $role

エージェントロール

string $dir

ディレクトリパス

string $fileName

ファイル名ベース

string $ext

ファイル名拡張子

Returns

string

_exception()

_exception(string  $msg, array  $config = array()) : \BEAR_Exception

例外の作成

Parameters

string $msg

例外メッセージ

array $config

例外config

Returns

\BEAR_Exception

_getRoleLayoutValue()

_getRoleLayoutValue(array  $role, array  $yml) : array

レイアウトバリューの取得

レイアウトymlファイルに記述されたスタティック変数がロール通りにあれば使用します。

Parameters

array $role

ロール

array $yml

ymlファイルの値

Returns

array

_getTemplateNameByPageClass()

_getTemplateNameByPageClass(string  $tplName) : string

ページクラスからパスを取得する

/はじまりだと絶対パス、テンプレート名省略または相対パスなら
ページクラスからパス名を組み立てます。相対パスでテンプレートを
指定していれば指定したものにおきかわる。

例
絶対パス
 '/index.tpl' => '/index'
 '/some/index.tpl' => '/some/index'
相対パス Sample_Test_Pageクラスの場合
 '' => 'sample/test/page'
 'help.tpl' => 'sample/test/help'
 'another/help.tpl' => 'sample/test/another/help'

Parameters

string $tplName

テンプレート名

Returns

string

_removeExtention()

_removeExtention(string  $file) : string

ファイルの拡張子を除いたものを返します

Parameters

string $file

ファイル名

Returns

string

onPackEmoji()

onPackEmoji(  $match) 

Parameters

$match