Ejemplo n.º 1
0
 public function actionRender()
 {
     $competition = Competition::model()->findByPk($this->iRequest('competition_id'));
     $template = NewsTemplate::model()->findByPk($this->iRequest('template_id'));
     if ($competition === null || $template === null) {
         $this->ajaxOK(null);
     }
     $attributes = $template->attributes;
     $data = $this->generateTemplateData($competition);
     set_error_handler(function ($errno, $errstr) {
         throw new Exception($errstr);
     });
     try {
         foreach ($attributes as $key => $attribute) {
             $attributes[$key] = preg_replace_callback('|\\{([^}]+)\\}|i', function ($matches) use($data) {
                 $result = $this->evaluateExpression($matches[1], $data);
                 if (is_array($result)) {
                     $result = CHtml::normalizeUrl($result);
                 }
                 return $result;
             }, $attribute);
         }
     } catch (Exception $e) {
         $this->ajaxOK(null);
     }
     $this->ajaxOK($attributes);
 }
Ejemplo n.º 2
0
<div class="row">
  <div class="col-lg-12">
    <div class="portlet portlet-default">
      <div class="portlet-heading">
          <div class="portlet-title">
              <h4>新闻信息</h4>
          </div>
          <div class="clearfix"></div>
      </div>
      <div class="panel-collapse collapse in">
          <div class="portlet-body">
            <?php 
$form = $this->beginWidget('ActiveForm', array('htmlOptions' => array('class' => 'clearfix row'), 'enableClientValidation' => true));
?>
            <?php 
echo Html::formGroup($model, '', array('class' => 'col-lg-6'), '<label for="template_id">新闻模板</label>', CHtml::dropDownList('template_id', '', CHtml::listData(NewsTemplate::model()->findAll(), 'id', 'name'), array('prompt' => '', 'class' => 'form-control')), $form->error($model, 'title_zh', array('class' => 'text-danger')));
?>
            <?php 
echo Html::formGroup($model, '', array('class' => 'col-lg-6'), '<label for="template_id">比赛事件</label>', CHtml::dropDownList('competition_id', '', Competition::getRegistrationCompetitions(), array('prompt' => '', 'class' => 'form-control')), $form->error($model, 'title_zh', array('class' => 'text-danger')));
?>
            <div class="clearfix"></div>
            <?php 
echo Html::formGroup($model, 'title_zh', array('class' => 'col-lg-6'), $form->labelEx($model, 'title_zh', array('label' => '中文标题')), Html::activeTextField($model, 'title_zh'), $form->error($model, 'title_zh', array('class' => 'text-danger')));
?>
            <?php 
echo Html::formGroup($model, 'title', array('class' => 'col-lg-6'), $form->labelEx($model, 'title', array('label' => '英文标题')), Html::activeTextField($model, 'title'), $form->error($model, 'title', array('class' => 'text-danger')));
?>
            <div class="clearfix"></div>
            <?php 
echo Html::formGroup($model, 'date', array('class' => 'col-lg-6'), $form->labelEx($model, 'date', array('label' => '时间')), Html::activeTextField($model, 'date', array('class' => 'datetime-picker', 'data-date-format' => 'yyyy-mm-dd hh:ii:ss')), $form->error($model, 'date', array('class' => 'text-danger')));
?>