Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/openpne/OpenPNE3
Browse files Browse the repository at this point in the history
  • Loading branch information
fukamachi committed Jan 6, 2010
2 parents ef7113e + 2be5b85 commit 132f9a4
Show file tree
Hide file tree
Showing 69 changed files with 1,993 additions and 972 deletions.
7 changes: 7 additions & 0 deletions apps/pc_backend/config/routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ connection:
connection_list:
url: /connection
param: { module: connection, action: list }

default_template_help:
url: /help_template_format
param: { module: default, action: templateHelp }
requirements:
sf_method: [get]

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/**
* This file is part of the OpenPNE package.
* (c) OpenPNE Project (http://www.openpne.jp/)
*
* For the full copyright and license information, please view the LICENSE
* file and the NOTICE file that were distributed with this source code.
*/

/**
* default/templateHelp action
*
* @package OpenPNE
* @subpackage default
* @author Kousuke Ebihara <[email protected]>
*/
class templateHelpAction extends sfAction
{
/**
* Executes error action
*
* @param sfRequest $request A request object
*/
public function execute($request)
{
}
}
5 changes: 5 additions & 0 deletions apps/pc_backend/modules/default/config/view.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
topSuccess:
javascripts: [%SF_PROTOTYPE_WEB_DIR%/js/prototype]

templateHelpSuccess:
layout: plain
stylesheets: [main, -backend, template_help]

118 changes: 118 additions & 0 deletions apps/pc_backend/modules/default/templates/templateHelpSuccess.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<h1>テンプレートの書式</h1>

<h2>変数</h2>

<p><code>{{ ... }}</code> と記述することで、括弧に囲まれた変数を表示します。</p>

<p>変数が配列である場合は、 <code>.</code> (ドット) の後に続けて要素名を記述するか、もしくは PHP の配列のように <code>[ ]</code> (角括弧) を続け、括弧内に要素名を記述することで変数を表示できます。</p>

<p>そのテンプレート内で使用可能な変数は、各テンプレート編集ページの下部に一覧してあります。</p>

<div class="example">
<h3>書式例</h3>
<pre><code>
{{ foo }} // foo という変数を表示する
{{ foo.bar }} // foo という配列の bar という要素を表示する
{{ foo['bar'] }} // foo という配列の bar という要素を表示する
</code></pre>
</div>

<h2>条件分岐</h2>

<p>変数の内容によって表示するかしないかを分岐させるには、 <code>if</code> 構文を使用します。</p>
<p><code>if</code> 構文を終了させるには、 <code>endif</code> を使用します。</p>

<div class="example">
<h3>書式例</h3>
<p>以下は、 ID1 のメンバーの場合に特定の文言を表示させるサンプルになります。</p>
<pre><code>
{% if member.id == "1" %}
管理者のメンバーです。
{% endif %}
</code></pre>
</div>

<h2>ループ</h2>

<p>配列の各要素に対して繰り返しの処理をおこないたい場合は、 <code>for</code> 構文を使用します。</p>
<p>members という配列の各要素に対して member という名前でアクセスしたい場合は <code>{% for members in member %}</code> というような記述になります。</p>

<div class="example">
<h3>書式例</h3>
<p>以下は、各メンバーの情報を格納した members という配列の各要素からニックネームを取り出し、表示させるサンプルです。</p>
<pre><code>
&lt;ul&gt;
{% for members in member %}
&lt;li&gt;{{ member.name }}&lt;/li&gt;
{% endfor %}
&lt;/ul&gt;
</code></pre>
</div>

<h2>演算子</h2>
<p>以下の演算子が使用できます。</p>
<dl>
<dt>+</dt>
<dd>左辺と右辺の値を加算した結果を返します</dd>
<dt>-</dt>
<dd>左辺と右辺の値を減算した結果を返します</dd>
<dt>/</dt>
<dd>左辺と右辺の値を除算した結果を返します</dd>
<dt>%</dt>
<dd>左辺と右辺の値を剰余算した結果を返します</dd>
<dt>*</dt>
<dd>左辺と右辺の値を乗算した結果を返します</dd>
<dt>and</dt>
<dd>左辺と右辺が真のときに真を返します</dd>
<dt>or</dt>
<dd>左辺か右辺が真のときに真を返します</dd>
<dt>==</dt>
<dd>左辺と右辺が同一の値の場合に真を返します</dd>
<dt>!=</dt>
<dd>左辺と右辺が同一でない値の場合に真を返します</dd>
<dt>&lt;</dt>
<dd>左辺よりも右辺が大きい値の場合に真を返します</dd>
<dt>&gt;</dt>
<dd>右辺よりも左辺が大きい値の場合に真を返します</dd>
<dt>&lt;=</dt>
<dd>右辺の値が左辺以上の値の場合に真を返します</dd>
<dt>&gt;=</dt>
<dd>左辺の値が右辺以上の値の場合に真を返します</dd>
</dl>

<h2>フィルター</h2>

<p>フィルターは、変数に対してフィルタリングをするための機能です。 <code>foo</code> 変数に <code>date</code> フィルターを使用したい場合は、 <code>{{ foo|date }}</code> というように、変数に <code>|</code> とフィルターを続けて記述します。</p>

<p>以下のフィルターが使用できます。</p>

<dl>
<dt>date</dt>
<dd>変数を引数で指定された日付フォーマットでフィルタリングします。
<div><pre><code>{{ member.config.lastLogin|date("Y年m月d日") }}</code></pre></div>
</dd>
<dt>default</dt>
<dd>変数が未定義だった場合、引数で指定された値を返します。
<div><pre><code>{{ undefined|default("デフォルト値") }}</code></pre></div>
</dd>
</dl>

<h2>参考情報</h2>

<p>OpenPNE では Twig というテンプレートエンジンを使用しています。</p>

<p>より詳細な情報は <a href="http://www.twig-project.org/documentation" target="_blank">Twig</a> のドキュメントを参照してください。</p>

19 changes: 19 additions & 0 deletions apps/pc_backend/modules/mail/templates/templateSuccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,25 @@
<?php echo $form['template']->render(array('rows' => 30, 'cols' => 72)) ?>

<input type="submit" value="<?php echo __('Save') ?>">

<p>テンプレートの書式については<?php echo link_to('こちら', '@default_template_help', array('popup' => true)) ?>を参照してください。</p>

<?php if (!empty($config[$_currentTarget][$_currentKey]['variables'])): ?>
<h4 style="margin-top: 10px">このテンプレートで使用可能な変数</h4>
<table>
<tr>
<th>変数名</th>
<th>説明</th>
</tr>
<?php foreach ($config[$_currentTarget][$_currentKey]['variables'] as $variable => $description): ?>
<tr>
<td><?php echo $variable ?></td>
<td><?php echo $description ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>

<?php endif; ?>
</td>
</tr>
Expand Down
3 changes: 3 additions & 0 deletions config/OpenPNE.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ mail_address_hash_length: 12
# ssl: "tls"
# port: 587

# メールテンプレートに機能制限をおこなうかどうか
# Add restriction to mail templates
is_restrict_mail_template: true

######################################
# セッション (Session)
Expand Down
Loading

0 comments on commit 132f9a4

Please sign in to comment.