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


PHP tpl::parseTemplate方法代码示例

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


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

示例1: getSurveyContent

 /**
  * getSurveyContent
  * Render the actual survey question for the specified form id that passed .
  *
  * @return string rendered template
  *
  * @param int    $formId   The id of the survey to get the content for.
  * @param tpl 	 $tpl	   This is the actual template system parsed from the front end
  */
 public function getSurveyContent($surveyId, $tpl)
 {
     // give the form an action to handle the submission
     // $tpl->Assign('action', 'admin/index.php?Page=Addons&Addon=surveys&Action=Submit&ajax=1&formId=' . $surveyId);
     $success_message = IEM::sessionGet('survey.addon.' . $surveyId . '.successMessage');
     if ($success_message) {
         IEM::sessionRemove('survey.addon.' . $surveyId . '.successMessage');
         $tpl->Assign('successMessage', $success_message);
         return $tpl->ParseTemplate('survey_success');
     }
     $tpl->Assign('action', 'surveys_submit.php?ajax=1&formId=' . $surveyId);
     // check for valid ID
     if (!isset($surveyId)) {
         return;
     }
     require_once 'widgets.php';
     $widgets_api = new Addons_survey_widgets_api();
     $loadRes = $this->Load($surveyId);
     if ($loadRes === false) {
         echo 'invalid form id';
         return;
     }
     $surveyData = $this->GetData();
     $widgets = $this->getWidgets($this->id);
     // and if there are widgets
     // iterate through each one
     $widgetErrors = array();
     if ($widgets) {
         $widgetErrors = IEM::sessionGet('survey.addon.' . $surveyId . '.widgetErrors');
         foreach ($widgets as $k => &$widget) {
             if ($widget['is_visible'] == 1 || $widget['type'] == 'section.break') {
                 // $widget->className = Interspire_String::camelCase($widget->type, true);
                 // Getting error from form..
                 $widget['className'] = 'Widget_' . str_replace('.', '_', $widget['type']);
                 $widgets_api->SetId($widget['id']);
                 $widget['fields'] = $widgets_api->getFields(false);
                 // if there are errors for this widget, set them
                 if ($widgetErrors && count($widgetErrors[$widget['id']]) > 0) {
                     $widget['errors'] = $widgetErrors[$widget['id']];
                 }
                 // randomize the fields if told to do so
                 if ($widget['is_random'] == 1) {
                     shuffle($widget['fields']);
                 }
                 // tack on an other field if one exists
                 if ($otherField = $widgets_api->getOtherField()) {
                     $otherField['value'] = '__other__';
                     $widget['fields'][] = $otherField;
                 }
                 // if it is a file widget, then grab the file types
                 if ($widget['type'] == 'file') {
                     $widget['fileTypes'] = preg_split('/\\s*,\\s*/', $widget['allowed_file_types']);
                     $widget['lastFileType'] = array_pop($widget['fileTypes']);
                 }
                 // assign the widget information to the view
                 $tpl->Assign('widget', $widget);
                 // render the widget template
                 $widget['template'] = $tpl->parseTemplate('widget.front.' . $widget['type'], true);
             } else {
                 unset($widgets[$k]);
             }
         }
         // clear the widget errors session variable
         IEM::sessionRemove('survey.addon.' . $surveyId . '.widgetErrors');
     }
     // assign the form, widget and widget-field data to the template
     $tpl->Assign('errorMessage', IEM::sessionGet('survey.addon.' . $surveyId . '.errorMessage'));
     $tpl->Assign('successMessage', IEM::sessionGet('survey.addon.' . $surveyId . '.successMessage'));
     $tpl->Assign('survey', $surveyData);
     $tpl->Assign('widgets', $widgets);
     // unset the message that was set, so it doesn't get displayed again
     IEM::sessionRemove('survey.addon.' . $surveyId . '.errorMessage');
     IEM::sessionRemove('survey.addon.' . $surveyId . '.successMessage');
     //return $this->template->parseTemplate('form', true);
     return $tpl->ParseTemplate('survey');
 }
开发者ID:hungnv0789,项目名称:vhtm,代码行数:85,代码来源:surveys.php


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