当前位置: 首页>>代码示例>>PHP>>正文


PHP Parse::Template方法代码示例

本文整理汇总了PHP中Parse::Template方法的典型用法代码示例。如果您正苦于以下问题:PHP Parse::Template方法的具体用法?PHP Parse::Template怎么用?PHP Parse::Template使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Parse的用法示例。


在下文中一共展示了Parse::Template方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: form

 /**
  * Raven form tag pair
  *
  * {{ raven:form }} {{ /raven:form }}
  *
  * @return string
  */
 public function form()
 {
     /*
     |--------------------------------------------------------------------------
     | Formset
     |--------------------------------------------------------------------------
     |
     | Raven really needs a formset to make it useful and secure. We may even
     | write a form decorator in the future to generate forms from formsets.
     |
     */
     $formset = $this->fetchParam('formset', false);
     $return = $this->fetchParam('return', URL::getCurrent());
     $error_return = $this->fetchParam('error_return', URL::getCurrent());
     $multipart = $this->fetchParam('files', false) ? "enctype='multipart/form-data'" : '';
     // Sanitize data before returning it for display
     $old_values = array_map('htmlspecialchars', $this->flash->get('old_values', array()));
     // Set old values to re-populate the form
     $data = array();
     array_set($data, 'value', $old_values);
     array_set($data, 'old_values', $old_values);
     /*
     |--------------------------------------------------------------------------
     | Form HTML
     |--------------------------------------------------------------------------
     |
     | Raven writes a few hidden fields to the form to help processing data go
     | more smoothly. Form attributes are accepted as colon/piped options:
     | Example: attr="class:form|id:contact-form"
     |
     | Note: The content of the tag pair is inserted back into the template
     |
     */
     $form_id = $this->fetchParam('id', true);
     $attributes_string = '';
     if ($attr = $this->fetchParam('attr', false)) {
         $attributes_array = Helper::explodeOptions($attr, true);
         foreach ($attributes_array as $key => $value) {
             $attributes_string .= " {$key}='{$value}'";
         }
     }
     $html = "<form method='post' {$multipart} {$attributes_string}>\n";
     $html .= "<input type='hidden' name='hidden[raven]' value='{$form_id}' />\n";
     $html .= "<input type='hidden' name='hidden[formset]' value='{$formset}' />\n";
     $html .= "<input type='hidden' name='hidden[return]' value='{$return}' />\n";
     $html .= "<input type='hidden' name='hidden[error_return]' value='{$error_return}' />\n";
     /*
     |--------------------------------------------------------------------------
     | Hook: Form Begin
     |--------------------------------------------------------------------------
     |
     | Occurs in the middle the form allowing additional fields to be added.
     | Has access to the current fieldset. Must return HTML.
     |
     */
     $html .= Hook::run('raven', 'inside_form', 'cumulative', '');
     /*
     |--------------------------------------------------------------------------
     | Hook: Content Preparse
     |--------------------------------------------------------------------------
     |
     | Allows the modification of the tag data inside the form. Also has access
     | to the current formset.
     |
     */
     $html .= Hook::run('raven', 'content_preparse', 'replace', $this->content, $this->content);
     $html .= "</form>";
     return Parse::Template($html, $data);
 }
开发者ID:jeffreyDcreative,项目名称:gkp,代码行数:76,代码来源:pi.raven.php


注:本文中的Parse::Template方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。