@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 5 | 5 | <!-- URLヘルパーのbase_url()メソッドは、メイン設定ファイルで設定した |
| 6 | 6 | base_urlを返します。 --> |
| 7 | -<link rel="stylesheet" href="<?=base_url('css/form.css');?>" type="text/css" /> |
|
| 7 | +<link rel="stylesheet" href="<?=base_url('css/form.css'); ?>" type="text/css" /> |
|
| 8 | 8 | <title>コンタクトフォーム</title> |
| 9 | 9 | </head> |
| 10 | 10 | |
@@ -15,12 +15,12 @@ discard block |
||
| 15 | 15 | <!-- メイン部分です。 --> |
| 16 | 16 | <div id="main"> |
| 17 | 17 | <div class="title_banner"> |
| 18 | -<img src="<?=base_url('images/icons/form_titile.jpg');?>" alt="お問い合わせ" width="580" height="70" /> |
|
| 18 | +<img src="<?=base_url('images/icons/form_titile.jpg'); ?>" alt="お問い合わせ" width="580" height="70" /> |
|
| 19 | 19 | </div> |
| 20 | 20 | |
| 21 | 21 | <div class="outer_frame"> |
| 22 | 22 | <!-- Formヘルパーのform_open()メソッドで<form>タグを生成します。 --> |
| 23 | -<?=form_open('form/confirm');?> |
|
| 23 | +<?=form_open('form/confirm'); ?> |
|
| 24 | 24 | <table> |
| 25 | 25 | <tr><th>名前</th> |
| 26 | 26 | <td> |
@@ -30,20 +30,20 @@ discard block |
||
| 30 | 30 | 知れませんが、これは、検証でエラーの場合、この同じビューファイルを使って |
| 31 | 31 | フォームを表示するためです。このようにビューを使えば、最初のフォームの表示 |
| 32 | 32 | とエラー時のフォームの再表示を、ひとつのビューで済ますことができます。 --> |
| 33 | - <input type="text" name="name" value="<?=set_value('name');?>" size="30" /> |
|
| 33 | + <input type="text" name="name" value="<?=set_value('name'); ?>" size="30" /> |
|
| 34 | 34 | <!-- form_error('name')は、nameフィールドの検証で |
| 35 | 35 | エラーがあった場合に、表示するエラーメッセージを返します。 --> |
| 36 | - <?=form_error('name');?> |
|
| 36 | + <?=form_error('name'); ?> |
|
| 37 | 37 | </td></tr> |
| 38 | 38 | <tr><th>メールアドレス</th> |
| 39 | 39 | <td> |
| 40 | - <input type="text" name="email" value="<?=set_value('email');?>" size="30" /> |
|
| 41 | - <?=form_error('email');?> |
|
| 40 | + <input type="text" name="email" value="<?=set_value('email'); ?>" size="30" /> |
|
| 41 | + <?=form_error('email'); ?> |
|
| 42 | 42 | </td></tr> |
| 43 | 43 | <tr><th>コメント</th> |
| 44 | 44 | <td> |
| 45 | - <textarea name="comment" rows="4" cols="30"><?=set_value('comment');?></textarea> |
|
| 46 | - <?=form_error('comment');?> |
|
| 45 | + <textarea name="comment" rows="4" cols="30"><?=set_value('comment'); ?></textarea> |
|
| 46 | + <?=form_error('comment'); ?> |
|
| 47 | 47 | </td></tr> |
| 48 | 48 | <tr><td></td> |
| 49 | 49 | <td class="center"> |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | <!-- Formヘルパーのform_close()メソッドで</form>タグを生成します。 |
| 54 | 54 | form_open()メソッドを使った場合は、このメソッドを使うことでHTML文法 |
| 55 | 55 | チェッカのエラーを回避できます。 --> |
| 56 | -<?=form_close();?> |
|
| 56 | +<?=form_close(); ?> |
|
| 57 | 57 | </div> |
| 58 | 58 | </div> |
| 59 | 59 | |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | <html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja"> |
| 3 | 3 | <head> |
| 4 | 4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 5 | -<link rel="stylesheet" href="<?=base_url('css/form.css');?>" type="text/css" /> |
|
| 5 | +<link rel="stylesheet" href="<?=base_url('css/form.css'); ?>" type="text/css" /> |
|
| 6 | 6 | <title>コンタクトフォーム(確認)</title> |
| 7 | 7 | </head> |
| 8 | 8 | |
@@ -13,41 +13,41 @@ discard block |
||
| 13 | 13 | <!-- main --> |
| 14 | 14 | <div id="main"> |
| 15 | 15 | <div class="title_banner"> |
| 16 | -<img src="<?=base_url('images/icons/form_titile.jpg');?>" alt="お問い合わせ" width="580" height="70" /> |
|
| 16 | +<img src="<?=base_url('images/icons/form_titile.jpg'); ?>" alt="お問い合わせ" width="580" height="70" /> |
|
| 17 | 17 | </div> |
| 18 | 18 | |
| 19 | 19 | <div class="outer_frame"> |
| 20 | 20 | <p class="center">お問い合わせ内容の確認</p> |
| 21 | 21 | <table> |
| 22 | 22 | <tr><th>名前</th> |
| 23 | - <td><?=set_value('name');?></td> |
|
| 23 | + <td><?=set_value('name'); ?></td> |
|
| 24 | 24 | </tr> |
| 25 | 25 | <tr><th>メールアドレス</th> |
| 26 | - <td><?=set_value('email');?></td> |
|
| 26 | + <td><?=set_value('email'); ?></td> |
|
| 27 | 27 | </tr> |
| 28 | 28 | <tr><th>コメント</th> |
| 29 | - <td><pre><?=set_value('comment');?></pre></td> |
|
| 29 | + <td><pre><?=set_value('comment'); ?></pre></td> |
|
| 30 | 30 | </tr> |
| 31 | 31 | <tr><td></td> |
| 32 | 32 | <td class="center"> |
| 33 | 33 | <!-- 入力を修正するための、隠しフィールドに入力値を仕込んだ |
| 34 | 34 | フォームを表示します。Formヘルパーで値を表示する場合、自動的に文字参照に |
| 35 | 35 | 置換されます。 --> |
| 36 | - <?=form_open('form');?> |
|
| 37 | - <?=form_hidden('name', $this->input->post('name'));?> |
|
| 38 | - <?=form_hidden('email', $this->input->post('email'));?> |
|
| 39 | - <?=form_hidden('comment', $this->input->post('comment'));?> |
|
| 36 | + <?=form_open('form'); ?> |
|
| 37 | + <?=form_hidden('name', $this->input->post('name')); ?> |
|
| 38 | + <?=form_hidden('email', $this->input->post('email')); ?> |
|
| 39 | + <?=form_hidden('comment', $this->input->post('comment')); ?> |
|
| 40 | 40 | <input class="button" type="submit" value="修正" /> |
| 41 | - <?=form_close();?> |
|
| 41 | + <?=form_close(); ?> |
|
| 42 | 42 | <!-- 入力がOKの場合に、次の完了ページへ進むためのフォームを表示します。 |
| 43 | 43 | ここでも、同様に、隠しフィールドに入力値を仕込み、次のページに渡します。 |
| 44 | 44 | ワンタイムチケットを忘れないようにしましょう。 --> |
| 45 | - <?=form_open('form/send');?> |
|
| 46 | - <?=form_hidden('name', $this->input->post('name'));?> |
|
| 47 | - <?=form_hidden('email', $this->input->post('email'));?> |
|
| 48 | - <?=form_hidden('comment', $this->input->post('comment'));?> |
|
| 45 | + <?=form_open('form/send'); ?> |
|
| 46 | + <?=form_hidden('name', $this->input->post('name')); ?> |
|
| 47 | + <?=form_hidden('email', $this->input->post('email')); ?> |
|
| 48 | + <?=form_hidden('comment', $this->input->post('comment')); ?> |
|
| 49 | 49 | <input class="button" type="submit" value="送信" /> |
| 50 | - <?=form_close();?> |
|
| 50 | + <?=form_close(); ?> |
|
| 51 | 51 | </td> |
| 52 | 52 | </tr> |
| 53 | 53 | </table> |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | <html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja"> |
| 3 | 3 | <head> |
| 4 | 4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 5 | -<link rel="stylesheet" href="<?=base_url('css/form.css');?>" type="text/css" /> |
|
| 5 | +<link rel="stylesheet" href="<?=base_url('css/form.css'); ?>" type="text/css" /> |
|
| 6 | 6 | <title>コンタクトフォーム(送信完了)</title> |
| 7 | 7 | </head> |
| 8 | 8 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | <!-- main --> |
| 14 | 14 | <div id="main"> |
| 15 | 15 | <div class="title_banner"> |
| 16 | -<img src="<?=base_url('images/icons/form_titile.jpg');?>" alt="お問い合わせ" width="580" height="70" /> |
|
| 16 | +<img src="<?=base_url('images/icons/form_titile.jpg'); ?>" alt="お問い合わせ" width="580" height="70" /> |
|
| 17 | 17 | </div> |
| 18 | 18 | |
| 19 | 19 | <div class="outer_frame"> |
@@ -2,10 +2,10 @@ |
||
| 2 | 2 | <div class="top_title"></div> |
| 3 | 3 | <div class="navi"> |
| 4 | 4 | <ul class="sitenavi"> |
| 5 | - <li class="menu_1"><img src="<?=base_url('images/icons/navi_icon-3.jpg');?>" alt="from" /></li> |
|
| 6 | - <li class="menu_2"><a href="<?=$this->config->site_url('form');?>">CIコンタクトフォーム</a></li> |
|
| 7 | - <li class="menu_1"><img src="<?=base_url('images/icons/navi_icon-4.jpg');?>" alt="home" /></li> |
|
| 8 | - <li class="menu_2"><a href="<?=base_url();?>">HOME</a></li> |
|
| 5 | + <li class="menu_1"><img src="<?=base_url('images/icons/navi_icon-3.jpg'); ?>" alt="from" /></li> |
|
| 6 | + <li class="menu_2"><a href="<?=$this->config->site_url('form'); ?>">CIコンタクトフォーム</a></li> |
|
| 7 | + <li class="menu_1"><img src="<?=base_url('images/icons/navi_icon-4.jpg'); ?>" alt="home" /></li> |
|
| 8 | + <li class="menu_2"><a href="<?=base_url(); ?>">HOME</a></li> |
|
| 9 | 9 | </ul> |
| 10 | 10 | </div> |
| 11 | 11 | <div class="top_kage"></div> |
@@ -3,23 +3,23 @@ discard block |
||
| 3 | 3 | <head> |
| 4 | 4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 5 | 5 | <title>CodeIgniterへようこそ!</title> |
| 6 | -<link href="<?=base_url('css/top.css');?>" rel="stylesheet" type="text/css" /> |
|
| 7 | -<script type="text/javascript" src="<?=base_url('js/bbs.js');?>"></script> |
|
| 6 | +<link href="<?=base_url('css/top.css'); ?>" rel="stylesheet" type="text/css" /> |
|
| 7 | +<script type="text/javascript" src="<?=base_url('js/bbs.js'); ?>"></script> |
|
| 8 | 8 | </head> |
| 9 | 9 | |
| 10 | -<body onload="MM_preloadImages('<?=base_url('images/icons/top_link_1on.jpg');?>','<?=base_url('images/icons/top_link_2on.jpg');?>','<?=base_url('images/icons/top_link_3on.jpg');?>')"> |
|
| 10 | +<body onload="MM_preloadImages('<?=base_url('images/icons/top_link_1on.jpg'); ?>','<?=base_url('images/icons/top_link_2on.jpg'); ?>','<?=base_url('images/icons/top_link_3on.jpg'); ?>')"> |
|
| 11 | 11 | <div id="header"> |
| 12 | 12 | <div class="top_title"></div> |
| 13 | 13 | <div class="navi"> |
| 14 | 14 | <ul class="sitenavi"> |
| 15 | - <li class="menu_1"><img src="<?=base_url('images/icons/navi_icon-3.jpg');?>" alt="from" /></li> |
|
| 16 | - <li class="menu_2"><a href="<?=$this->config->site_url('form');?>">CIコンタクトフォーム</a></li> |
|
| 17 | - <li class="menu_1"><img src="<?=base_url('images/icons/navi_icon-2.jpg');?>" alt="bbs" /></li> |
|
| 18 | - <li class="menu_2"><a href="<?=$this->config->site_url('bbs');?>">CI掲示板</a></li> |
|
| 19 | - <li class="menu_1"><img src="<?=base_url('images/icons/navi_icon-1.jpg');?>" alt="shop" /></li> |
|
| 20 | - <li class="menu_2"><a href="<?=$this->config->site_url('shops');?>">CIショッピング</a></li> |
|
| 21 | - <li class="menu_1"><img src="<?=base_url('images/icons/navi_icon-4.jpg');?>" alt="home" /></li> |
|
| 22 | - <li class="menu_2"><a href="<?=$this->config->site_url();?>">HOME</a></li> |
|
| 15 | + <li class="menu_1"><img src="<?=base_url('images/icons/navi_icon-3.jpg'); ?>" alt="from" /></li> |
|
| 16 | + <li class="menu_2"><a href="<?=$this->config->site_url('form'); ?>">CIコンタクトフォーム</a></li> |
|
| 17 | + <li class="menu_1"><img src="<?=base_url('images/icons/navi_icon-2.jpg'); ?>" alt="bbs" /></li> |
|
| 18 | + <li class="menu_2"><a href="<?=$this->config->site_url('bbs'); ?>">CI掲示板</a></li> |
|
| 19 | + <li class="menu_1"><img src="<?=base_url('images/icons/navi_icon-1.jpg'); ?>" alt="shop" /></li> |
|
| 20 | + <li class="menu_2"><a href="<?=$this->config->site_url('shops'); ?>">CIショッピング</a></li> |
|
| 21 | + <li class="menu_1"><img src="<?=base_url('images/icons/navi_icon-4.jpg'); ?>" alt="home" /></li> |
|
| 22 | + <li class="menu_2"><a href="<?=$this->config->site_url(); ?>">HOME</a></li> |
|
| 23 | 23 | </ul> |
| 24 | 24 | </div> |
| 25 | 25 | <div class="top_kage"></div> |
@@ -28,16 +28,16 @@ discard block |
||
| 28 | 28 | <div id="main"> |
| 29 | 29 | <div class="top_navi"> |
| 30 | 30 | <div class="top_sitenavi"> |
| 31 | - <a href="<?=$this->config->site_url();?>form" target="_top"> |
|
| 32 | - <img src="<?=base_url('images/icons/top_link_3off.jpg');?>" alt="CIコンタクトフォーム" name="navi3" width="220" height="220" border="0" id="navi3" onmouseover="MM_swapImage('navi3','','<?=base_url('images/icons/top_link_3on.jpg');?>',1)" onmouseout="MM_swapImgRestore()" /></a> |
|
| 31 | + <a href="<?=$this->config->site_url(); ?>form" target="_top"> |
|
| 32 | + <img src="<?=base_url('images/icons/top_link_3off.jpg'); ?>" alt="CIコンタクトフォーム" name="navi3" width="220" height="220" border="0" id="navi3" onmouseover="MM_swapImage('navi3','','<?=base_url('images/icons/top_link_3on.jpg'); ?>',1)" onmouseout="MM_swapImgRestore()" /></a> |
|
| 33 | 33 | </div> |
| 34 | 34 | <div class="top_sitenavi"> |
| 35 | - <a href="<?=$this->config->site_url();?>bbs" target="_top"> |
|
| 36 | - <img src="<?=base_url('images/icons/top_link_2off.jpg');?>" alt="CI掲示板" name="navi2" width="220" height="220" border="0" id="navi2" onmouseover="MM_swapImage('navi2','','<?=base_url('images/icons/top_link_2on.jpg');?>',1)" onmouseout="MM_swapImgRestore()" /></a> |
|
| 35 | + <a href="<?=$this->config->site_url(); ?>bbs" target="_top"> |
|
| 36 | + <img src="<?=base_url('images/icons/top_link_2off.jpg'); ?>" alt="CI掲示板" name="navi2" width="220" height="220" border="0" id="navi2" onmouseover="MM_swapImage('navi2','','<?=base_url('images/icons/top_link_2on.jpg'); ?>',1)" onmouseout="MM_swapImgRestore()" /></a> |
|
| 37 | 37 | </div> |
| 38 | 38 | <div class="top_sitenavi"> |
| 39 | - <a href="<?=$this->config->site_url();?>shop" target="_top"> |
|
| 40 | - <img src="<?=base_url('images/icons/top_link_1off.jpg');?>" alt="CIショッピング" name="navi1" width="220" height="220" border="0" id="navi1" onmouseover="MM_swapImage('navi1','','<?=base_url('images/icons/top_link_1on.jpg');?>',1)" onmouseout="MM_swapImgRestore()" /></a> |
|
| 39 | + <a href="<?=$this->config->site_url(); ?>shop" target="_top"> |
|
| 40 | + <img src="<?=base_url('images/icons/top_link_1off.jpg'); ?>" alt="CIショッピング" name="navi1" width="220" height="220" border="0" id="navi1" onmouseover="MM_swapImage('navi1','','<?=base_url('images/icons/top_link_1on.jpg'); ?>',1)" onmouseout="MM_swapImgRestore()" /></a> |
|
| 41 | 41 | </div> |
| 42 | 42 | </div> |
| 43 | 43 | </div> |
@@ -82,7 +82,7 @@ |
||
| 82 | 82 | <p>If you are exploring CodeIgniter for the very first time, you should start by reading the <a href="user_guide/">User Guide</a>.</p> |
| 83 | 83 | </div> |
| 84 | 84 | |
| 85 | - <p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds. <?php echo (ENVIRONMENT === 'development') ? 'CodeIgniter Version <strong>' . CI_VERSION . '</strong>' : '' ?></p> |
|
| 85 | + <p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds. <?php echo (ENVIRONMENT === 'development') ? 'CodeIgniter Version <strong>'.CI_VERSION.'</strong>' : '' ?></p> |
|
| 86 | 86 | </div> |
| 87 | 87 | |
| 88 | 88 | </body> |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | </table> |
| 28 | 28 | |
| 29 | 29 | <hr> |
| 30 | -<?=anchor('bbs', 'トップに戻る');?> |
|
| 30 | +<?=anchor('bbs', 'トップに戻る'); ?> |
|
| 31 | 31 | |
| 32 | 32 | </body> |
| 33 | 33 | </html> |
@@ -17,242 +17,242 @@ |
||
| 17 | 17 | |
| 18 | 18 | class Twig |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @var array Paths to Twig templates |
|
| 22 | - */ |
|
| 23 | - private $paths = []; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @var array Twig Environment Options |
|
| 27 | - * @see http://twig.sensiolabs.org/doc/api.html#environment-options |
|
| 28 | - */ |
|
| 29 | - private $config = []; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var array Functions to add to Twig |
|
| 33 | - */ |
|
| 34 | - private $functions_asis = [ |
|
| 35 | - 'base_url', 'site_url', |
|
| 36 | - ]; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var array Functions with `is_safe` option |
|
| 40 | - * @see http://twig.sensiolabs.org/doc/advanced.html#automatic-escaping |
|
| 41 | - */ |
|
| 42 | - private $functions_safe = [ |
|
| 43 | - 'form_open', 'form_close', 'form_error', 'form_hidden', 'set_value', |
|
| 20 | + /** |
|
| 21 | + * @var array Paths to Twig templates |
|
| 22 | + */ |
|
| 23 | + private $paths = []; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @var array Twig Environment Options |
|
| 27 | + * @see http://twig.sensiolabs.org/doc/api.html#environment-options |
|
| 28 | + */ |
|
| 29 | + private $config = []; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var array Functions to add to Twig |
|
| 33 | + */ |
|
| 34 | + private $functions_asis = [ |
|
| 35 | + 'base_url', 'site_url', |
|
| 36 | + ]; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var array Functions with `is_safe` option |
|
| 40 | + * @see http://twig.sensiolabs.org/doc/advanced.html#automatic-escaping |
|
| 41 | + */ |
|
| 42 | + private $functions_safe = [ |
|
| 43 | + 'form_open', 'form_close', 'form_error', 'form_hidden', 'set_value', |
|
| 44 | 44 | // 'form_open_multipart', 'form_upload', 'form_submit', 'form_dropdown', |
| 45 | 45 | // 'set_radio', 'set_select', 'set_checkbox', |
| 46 | - ]; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var bool Whether functions are added or not |
|
| 50 | - */ |
|
| 51 | - private $functions_added = FALSE; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @var Twig_Environment |
|
| 55 | - */ |
|
| 56 | - private $twig; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @var Twig_Loader_Filesystem |
|
| 60 | - */ |
|
| 61 | - private $loader; |
|
| 62 | - |
|
| 63 | - public function __construct($params = []) |
|
| 64 | - { |
|
| 65 | - if (isset($params['functions'])) |
|
| 66 | - { |
|
| 67 | - $this->functions_asis = |
|
| 68 | - array_unique( |
|
| 69 | - array_merge($this->functions_asis, $params['functions']) |
|
| 70 | - ); |
|
| 71 | - unset($params['functions']); |
|
| 72 | - } |
|
| 73 | - if (isset($params['functions_safe'])) |
|
| 74 | - { |
|
| 75 | - $this->functions_safe = |
|
| 76 | - array_unique( |
|
| 77 | - array_merge($this->functions_safe, $params['functions_safe']) |
|
| 78 | - ); |
|
| 79 | - unset($params['functions_safe']); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - if (isset($params['paths'])) |
|
| 83 | - { |
|
| 84 | - $this->paths = $params['paths']; |
|
| 85 | - unset($params['paths']); |
|
| 86 | - } |
|
| 87 | - else |
|
| 88 | - { |
|
| 89 | - $this->paths = [VIEWPATH]; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - // default Twig config |
|
| 93 | - $this->config = [ |
|
| 94 | - 'cache' => APPPATH . 'cache/twig', |
|
| 95 | - 'debug' => ENVIRONMENT !== 'production', |
|
| 96 | - 'autoescape' => 'html', |
|
| 97 | - ]; |
|
| 98 | - |
|
| 99 | - $this->config = array_merge($this->config, $params); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - protected function resetTwig() |
|
| 103 | - { |
|
| 104 | - $this->twig = null; |
|
| 105 | - $this->createTwig(); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - protected function createTwig() |
|
| 109 | - { |
|
| 110 | - // $this->twig is singleton |
|
| 111 | - if ($this->twig !== null) |
|
| 112 | - { |
|
| 113 | - return; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - if ($this->loader === null) |
|
| 117 | - { |
|
| 118 | - $this->loader = new \Twig_Loader_Filesystem($this->paths); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - $twig = new \Twig_Environment($this->loader, $this->config); |
|
| 122 | - |
|
| 123 | - if ($this->config['debug']) |
|
| 124 | - { |
|
| 125 | - $twig->addExtension(new \Twig_Extension_Debug()); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - $this->twig = $twig; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - protected function setLoader($loader) |
|
| 132 | - { |
|
| 133 | - $this->loader = $loader; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Registers a Global |
|
| 138 | - * |
|
| 139 | - * @param string $name The global name |
|
| 140 | - * @param mixed $value The global value |
|
| 141 | - */ |
|
| 142 | - public function addGlobal($name, $value) |
|
| 143 | - { |
|
| 144 | - $this->createTwig(); |
|
| 145 | - $this->twig->addGlobal($name, $value); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * Renders Twig Template and Set Output |
|
| 150 | - * |
|
| 151 | - * @param string $view Template filename without `.twig` |
|
| 152 | - * @param array $params Array of parameters to pass to the template |
|
| 153 | - */ |
|
| 154 | - public function display($view, $params = []) |
|
| 155 | - { |
|
| 156 | - $CI =& get_instance(); |
|
| 157 | - $CI->output->set_output($this->render($view, $params)); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * Renders Twig Template and Returns as String |
|
| 162 | - * |
|
| 163 | - * @param string $view Template filename without `.twig` |
|
| 164 | - * @param array $params Array of parameters to pass to the template |
|
| 165 | - * @return string |
|
| 166 | - */ |
|
| 167 | - public function render($view, $params = []) |
|
| 168 | - { |
|
| 169 | - $this->createTwig(); |
|
| 170 | - // We call addFunctions() here, because we must call addFunctions() |
|
| 171 | - // after loading CodeIgniter functions in a controller. |
|
| 172 | - $this->addFunctions(); |
|
| 173 | - |
|
| 174 | - $view = $view . '.twig'; |
|
| 175 | - return $this->twig->render($view, $params); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - protected function addFunctions() |
|
| 179 | - { |
|
| 180 | - // Runs only once |
|
| 181 | - if ($this->functions_added) |
|
| 182 | - { |
|
| 183 | - return; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - // as is functions |
|
| 187 | - foreach ($this->functions_asis as $function) |
|
| 188 | - { |
|
| 189 | - if (function_exists($function)) |
|
| 190 | - { |
|
| 191 | - $this->twig->addFunction( |
|
| 192 | - new \Twig_SimpleFunction( |
|
| 193 | - $function, |
|
| 194 | - $function |
|
| 195 | - ) |
|
| 196 | - ); |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - // safe functions |
|
| 201 | - foreach ($this->functions_safe as $function) |
|
| 202 | - { |
|
| 203 | - if (function_exists($function)) |
|
| 204 | - { |
|
| 205 | - $this->twig->addFunction( |
|
| 206 | - new \Twig_SimpleFunction( |
|
| 207 | - $function, |
|
| 208 | - $function, |
|
| 209 | - ['is_safe' => ['html']] |
|
| 210 | - ) |
|
| 211 | - ); |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - // customized functions |
|
| 216 | - if (function_exists('anchor')) |
|
| 217 | - { |
|
| 218 | - $this->twig->addFunction( |
|
| 219 | - new \Twig_SimpleFunction( |
|
| 220 | - 'anchor', |
|
| 221 | - [$this, 'safe_anchor'], |
|
| 222 | - ['is_safe' => ['html']] |
|
| 223 | - ) |
|
| 224 | - ); |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - $this->functions_added = TRUE; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * @param string $uri |
|
| 232 | - * @param string $title |
|
| 233 | - * @param array $attributes [changed] only array is acceptable |
|
| 234 | - * @return string |
|
| 235 | - */ |
|
| 236 | - public function safe_anchor($uri = '', $title = '', $attributes = []) |
|
| 237 | - { |
|
| 238 | - $uri = html_escape($uri); |
|
| 239 | - $title = html_escape($title); |
|
| 240 | - |
|
| 241 | - $new_attr = []; |
|
| 242 | - foreach ($attributes as $key => $val) |
|
| 243 | - { |
|
| 244 | - $new_attr[html_escape($key)] = html_escape($val); |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - return anchor($uri, $title, $new_attr); |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * @return \Twig_Environment |
|
| 252 | - */ |
|
| 253 | - public function getTwig() |
|
| 254 | - { |
|
| 255 | - $this->createTwig(); |
|
| 256 | - return $this->twig; |
|
| 257 | - } |
|
| 46 | + ]; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var bool Whether functions are added or not |
|
| 50 | + */ |
|
| 51 | + private $functions_added = FALSE; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @var Twig_Environment |
|
| 55 | + */ |
|
| 56 | + private $twig; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @var Twig_Loader_Filesystem |
|
| 60 | + */ |
|
| 61 | + private $loader; |
|
| 62 | + |
|
| 63 | + public function __construct($params = []) |
|
| 64 | + { |
|
| 65 | + if (isset($params['functions'])) |
|
| 66 | + { |
|
| 67 | + $this->functions_asis = |
|
| 68 | + array_unique( |
|
| 69 | + array_merge($this->functions_asis, $params['functions']) |
|
| 70 | + ); |
|
| 71 | + unset($params['functions']); |
|
| 72 | + } |
|
| 73 | + if (isset($params['functions_safe'])) |
|
| 74 | + { |
|
| 75 | + $this->functions_safe = |
|
| 76 | + array_unique( |
|
| 77 | + array_merge($this->functions_safe, $params['functions_safe']) |
|
| 78 | + ); |
|
| 79 | + unset($params['functions_safe']); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + if (isset($params['paths'])) |
|
| 83 | + { |
|
| 84 | + $this->paths = $params['paths']; |
|
| 85 | + unset($params['paths']); |
|
| 86 | + } |
|
| 87 | + else |
|
| 88 | + { |
|
| 89 | + $this->paths = [VIEWPATH]; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + // default Twig config |
|
| 93 | + $this->config = [ |
|
| 94 | + 'cache' => APPPATH . 'cache/twig', |
|
| 95 | + 'debug' => ENVIRONMENT !== 'production', |
|
| 96 | + 'autoescape' => 'html', |
|
| 97 | + ]; |
|
| 98 | + |
|
| 99 | + $this->config = array_merge($this->config, $params); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + protected function resetTwig() |
|
| 103 | + { |
|
| 104 | + $this->twig = null; |
|
| 105 | + $this->createTwig(); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + protected function createTwig() |
|
| 109 | + { |
|
| 110 | + // $this->twig is singleton |
|
| 111 | + if ($this->twig !== null) |
|
| 112 | + { |
|
| 113 | + return; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + if ($this->loader === null) |
|
| 117 | + { |
|
| 118 | + $this->loader = new \Twig_Loader_Filesystem($this->paths); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + $twig = new \Twig_Environment($this->loader, $this->config); |
|
| 122 | + |
|
| 123 | + if ($this->config['debug']) |
|
| 124 | + { |
|
| 125 | + $twig->addExtension(new \Twig_Extension_Debug()); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + $this->twig = $twig; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + protected function setLoader($loader) |
|
| 132 | + { |
|
| 133 | + $this->loader = $loader; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Registers a Global |
|
| 138 | + * |
|
| 139 | + * @param string $name The global name |
|
| 140 | + * @param mixed $value The global value |
|
| 141 | + */ |
|
| 142 | + public function addGlobal($name, $value) |
|
| 143 | + { |
|
| 144 | + $this->createTwig(); |
|
| 145 | + $this->twig->addGlobal($name, $value); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * Renders Twig Template and Set Output |
|
| 150 | + * |
|
| 151 | + * @param string $view Template filename without `.twig` |
|
| 152 | + * @param array $params Array of parameters to pass to the template |
|
| 153 | + */ |
|
| 154 | + public function display($view, $params = []) |
|
| 155 | + { |
|
| 156 | + $CI =& get_instance(); |
|
| 157 | + $CI->output->set_output($this->render($view, $params)); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * Renders Twig Template and Returns as String |
|
| 162 | + * |
|
| 163 | + * @param string $view Template filename without `.twig` |
|
| 164 | + * @param array $params Array of parameters to pass to the template |
|
| 165 | + * @return string |
|
| 166 | + */ |
|
| 167 | + public function render($view, $params = []) |
|
| 168 | + { |
|
| 169 | + $this->createTwig(); |
|
| 170 | + // We call addFunctions() here, because we must call addFunctions() |
|
| 171 | + // after loading CodeIgniter functions in a controller. |
|
| 172 | + $this->addFunctions(); |
|
| 173 | + |
|
| 174 | + $view = $view . '.twig'; |
|
| 175 | + return $this->twig->render($view, $params); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + protected function addFunctions() |
|
| 179 | + { |
|
| 180 | + // Runs only once |
|
| 181 | + if ($this->functions_added) |
|
| 182 | + { |
|
| 183 | + return; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + // as is functions |
|
| 187 | + foreach ($this->functions_asis as $function) |
|
| 188 | + { |
|
| 189 | + if (function_exists($function)) |
|
| 190 | + { |
|
| 191 | + $this->twig->addFunction( |
|
| 192 | + new \Twig_SimpleFunction( |
|
| 193 | + $function, |
|
| 194 | + $function |
|
| 195 | + ) |
|
| 196 | + ); |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + // safe functions |
|
| 201 | + foreach ($this->functions_safe as $function) |
|
| 202 | + { |
|
| 203 | + if (function_exists($function)) |
|
| 204 | + { |
|
| 205 | + $this->twig->addFunction( |
|
| 206 | + new \Twig_SimpleFunction( |
|
| 207 | + $function, |
|
| 208 | + $function, |
|
| 209 | + ['is_safe' => ['html']] |
|
| 210 | + ) |
|
| 211 | + ); |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + // customized functions |
|
| 216 | + if (function_exists('anchor')) |
|
| 217 | + { |
|
| 218 | + $this->twig->addFunction( |
|
| 219 | + new \Twig_SimpleFunction( |
|
| 220 | + 'anchor', |
|
| 221 | + [$this, 'safe_anchor'], |
|
| 222 | + ['is_safe' => ['html']] |
|
| 223 | + ) |
|
| 224 | + ); |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + $this->functions_added = TRUE; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * @param string $uri |
|
| 232 | + * @param string $title |
|
| 233 | + * @param array $attributes [changed] only array is acceptable |
|
| 234 | + * @return string |
|
| 235 | + */ |
|
| 236 | + public function safe_anchor($uri = '', $title = '', $attributes = []) |
|
| 237 | + { |
|
| 238 | + $uri = html_escape($uri); |
|
| 239 | + $title = html_escape($title); |
|
| 240 | + |
|
| 241 | + $new_attr = []; |
|
| 242 | + foreach ($attributes as $key => $val) |
|
| 243 | + { |
|
| 244 | + $new_attr[html_escape($key)] = html_escape($val); |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + return anchor($uri, $title, $new_attr); |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * @return \Twig_Environment |
|
| 252 | + */ |
|
| 253 | + public function getTwig() |
|
| 254 | + { |
|
| 255 | + $this->createTwig(); |
|
| 256 | + return $this->twig; |
|
| 257 | + } |
|
| 258 | 258 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | // default Twig config |
| 93 | 93 | $this->config = [ |
| 94 | - 'cache' => APPPATH . 'cache/twig', |
|
| 94 | + 'cache' => APPPATH.'cache/twig', |
|
| 95 | 95 | 'debug' => ENVIRONMENT !== 'production', |
| 96 | 96 | 'autoescape' => 'html', |
| 97 | 97 | ]; |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public function display($view, $params = []) |
| 155 | 155 | { |
| 156 | - $CI =& get_instance(); |
|
| 156 | + $CI = & get_instance(); |
|
| 157 | 157 | $CI->output->set_output($this->render($view, $params)); |
| 158 | 158 | } |
| 159 | 159 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | // after loading CodeIgniter functions in a controller. |
| 172 | 172 | $this->addFunctions(); |
| 173 | 173 | |
| 174 | - $view = $view . '.twig'; |
|
| 174 | + $view = $view.'.twig'; |
|
| 175 | 175 | return $this->twig->render($view, $params); |
| 176 | 176 | } |
| 177 | 177 | |
@@ -83,8 +83,7 @@ |
||
| 83 | 83 | { |
| 84 | 84 | $this->paths = $params['paths']; |
| 85 | 85 | unset($params['paths']); |
| 86 | - } |
|
| 87 | - else |
|
| 86 | + } else |
|
| 88 | 87 | { |
| 89 | 88 | $this->paths = [VIEWPATH]; |
| 90 | 89 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | { |
| 32 | 32 | # 引数から$offsetに値が渡されます。これは、3番目のURIセグメントの値です。 |
| 33 | 33 | # ユーザが変更可能なデータですので、int型へ変換し、必ず整数値にします。 |
| 34 | - $offset = (int) $offset; |
|
| 34 | + $offset = (int)$offset; |
|
| 35 | 35 | |
| 36 | 36 | # 新しい記事ID順に、limit値とoffset値を指定し、bbsテーブルから記事データ |
| 37 | 37 | # (オブジェクト)を取得し、$data['query']に代入します。order_by()メソッドは、 |
@@ -121,8 +121,8 @@ discard block |
||
| 121 | 121 | # メソッドを使い、ランダムな4桁の数字を取得します。 |
| 122 | 122 | $vals = [ |
| 123 | 123 | 'word' => random_string('numeric', 4), |
| 124 | - 'img_path' => FCPATH . 'captcha/', |
|
| 125 | - 'img_url' => base_url() . 'captcha/' |
|
| 124 | + 'img_path' => FCPATH.'captcha/', |
|
| 125 | + 'img_url' => base_url().'captcha/' |
|
| 126 | 126 | ]; |
| 127 | 127 | $cap = create_captcha($vals); |
| 128 | 128 | $data = [ |
@@ -149,12 +149,12 @@ discard block |
||
| 149 | 149 | public function delete($id = '') |
| 150 | 150 | { |
| 151 | 151 | # 第1引数、つまり、3番目のURIセグメントのデータをint型に変換します。 |
| 152 | - $id = (int) $id; |
|
| 152 | + $id = (int)$id; |
|
| 153 | 153 | # POSTされたpasswordフィールドの値を$passwordに代入します。 |
| 154 | 154 | $password = $this->input->post('password'); |
| 155 | 155 | # POSTされたdeleteフィールドの値を$deleteに代入します。この値が |
| 156 | 156 | # 1の場合は、削除を実行します。1以外は、削除の確認ページを表示します。 |
| 157 | - $delete = (int) $this->input->post('delete'); |
|
| 157 | + $delete = (int)$this->input->post('delete'); |
|
| 158 | 158 | |
| 159 | 159 | # 削除パスワードが入力されていない場合は、エラーページを表示します。 |
| 160 | 160 | if ($password == '') |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | # 有効期限を2時間に設定し、それ以前に生成されたキャプチャをデータベースから |
| 287 | 287 | # 削除します。delete()メソッドの第2引数では、「captcha_time <」を配列のキーに |
| 288 | 288 | # していますが、このように記述することで、WHERE句の条件の演算子を指定できます。 |
| 289 | - $expiration = time() - 7200; // 有効期限 2時間 |
|
| 289 | + $expiration = time() - 7200; // 有効期限 2時間 |
|
| 290 | 290 | $this->db->delete('captcha', ['captcha_time <' => $expiration]); |
| 291 | 291 | |
| 292 | 292 | # バリデーション(検証)クラスより引数$strに渡された、ユーザからの入力値がデータ |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | # 携帯端末の場合は、「_mobile」がファイル名に付くビューファイルをロードします。 |
| 325 | 325 | if ($this->agent->is_mobile()) |
| 326 | 326 | { |
| 327 | - $this->load->view($file . '_mobile', $data); |
|
| 327 | + $this->load->view($file.'_mobile', $data); |
|
| 328 | 328 | } |
| 329 | 329 | else |
| 330 | 330 | { |
@@ -61,8 +61,7 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | $config['full_tag_open'] = '<tr><td bgcolor="#EEEEEE">'; |
| 63 | 63 | $config['full_tag_close'] = '</td></tr>'; |
| 64 | - } |
|
| 65 | - else |
|
| 64 | + } else |
|
| 66 | 65 | { |
| 67 | 66 | $config['full_tag_open'] = '<p class="pagination">'; |
| 68 | 67 | $config['full_tag_close'] = '</p>'; |
@@ -98,8 +97,7 @@ discard block |
||
| 98 | 97 | $this->_delete_captcha_data(); |
| 99 | 98 | |
| 100 | 99 | $this->_show_post_page(); |
| 101 | - } |
|
| 102 | - else |
|
| 100 | + } else |
|
| 103 | 101 | { |
| 104 | 102 | $data = []; |
| 105 | 103 | $data['name'] = $this->input->post('name'); |
@@ -169,8 +167,7 @@ discard block |
||
| 169 | 167 | if ($password == '') |
| 170 | 168 | { |
| 171 | 169 | $this->_load_view('bbs_delete_error'); |
| 172 | - } |
|
| 173 | - else |
|
| 170 | + } else |
|
| 174 | 171 | { |
| 175 | 172 | # 記事IDと削除パスワードを条件として、bbsテーブルを検索します。 |
| 176 | 173 | $this->db->where('id', $id); |
@@ -223,8 +220,7 @@ discard block |
||
| 223 | 220 | if ($this->agent->is_mobile()) |
| 224 | 221 | { |
| 225 | 222 | $this->form_validation->set_error_delimiters('<div>', '</div>'); |
| 226 | - } |
|
| 227 | - else |
|
| 223 | + } else |
|
| 228 | 224 | { |
| 229 | 225 | $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); |
| 230 | 226 | } |
@@ -268,8 +264,7 @@ discard block |
||
| 268 | 264 | $this->_delete_captcha_data(); |
| 269 | 265 | |
| 270 | 266 | $this->_show_post_page(); |
| 271 | - } |
|
| 272 | - else |
|
| 267 | + } else |
|
| 273 | 268 | { |
| 274 | 269 | # 検証にパスした場合は、送られたデータとIPアドレスをbbsテーブルに登録します。 |
| 275 | 270 | $data = []; |
@@ -337,8 +332,7 @@ discard block |
||
| 337 | 332 | if ($this->agent->is_mobile()) |
| 338 | 333 | { |
| 339 | 334 | $this->load->view($file . '_mobile', $data); |
| 340 | - } |
|
| 341 | - else |
|
| 335 | + } else |
|
| 342 | 336 | { |
| 343 | 337 | $this->load->view($file, $data); |
| 344 | 338 | } |