public function actionCreate($fraid)
 {
     $model = new Fragment2Data();
     $model->fragment_id = $fraid;
     $model->publish_time = TTimeHelper::getCurrentTime();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index', 'fraid' => $fraid]);
     } else {
         $locals = [];
         $locals['model'] = $model;
         $locals['currentFragment'] = Fragment::findOne($fraid);
         return $this->render('create', $locals);
     }
 }
Example #2
0
 public function saveContent($model)
 {
     $model->removeSpecialAtt();
     $model->user_id = 1;
     $model->user_name = 'admin';
     $model->publish_time = TTimeHelper::getCurrentTime();
     $model->modify_time = TTimeHelper::getCurrentTime();
     $model->title_format = CommonContent::getFormatValue($model->title_format);
     $model->flag = CommonContent::getFlatValue($model->flag);
     $db = Yii::$app->db;
     $command = $db->createCommand();
     if ($model->isNewRecord) {
         $command->insert($this->currentTableName, $model);
     } else {
         $command->update($this->currentTableName, $model, ['id' => $model['id']]);
     }
     $command->execute();
 }
Example #3
0
 public function saveContent($model)
 {
     $model->removeSpecialAtt();
     $model->user_id = 1;
     $model->user_name = 'admin';
     $model->publish_time = TTimeHelper::getCurrentTime();
     $model->modify_time = TTimeHelper::getCurrentTime();
     $model->title_format = CommonUtility::getTitleFormatValue($model->title_format);
     $model->flag = CommonUtility::getFlagValue($model->flag);
     $uploadedFile = CommonUtility::uploadFile('Content[title_pic]');
     if ($uploadedFile != null) {
         $model->title_pic = $uploadedFile['url'] . $uploadedFile['new_name'];
     }
     if ($model->title_pic == null || empty($model->title_pic)) {
         $model->is_pic = 0;
     } else {
         $model->is_pic = 1;
     }
     if ($model->views == null) {
         $model->views = 0;
     }
     if ($model->commonts == null) {
         $model->commonts = 0;
     }
     if ($model->summary == null || empty($model->summary)) {
         $content = strip_tags($model->content);
         $pattern = '/\\s/';
         //去除空白
         $content = preg_replace($pattern, '', $content);
         $model->summary = TStringHelper::subStr($content, 250);
     }
     $command = LuLu::createCommand();
     if ($model->isNewRecord) {
         $command->insert($this->currentTableName, $model);
     } else {
         $command->update($this->currentTableName, $model, ['id' => $model['id']]);
     }
     $command->execute();
 }
Example #4
0
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         $this->title_format = CommonUtility::getTitleFormatValue($this->title_format);
         $uploadedFile = CommonUtility::uploadFile('Page[title_pic]');
         if ($uploadedFile != null) {
             $this->title_pic = $uploadedFile['url'] . $uploadedFile['new_name'];
         }
         if (!is_int($this->sort_num)) {
             $this->sort_num = 0;
         }
         $this->publish_time = TTimeHelper::getCurrentTime();
         $this->modify_time = TTimeHelper::getCurrentTime();
         if ($this->summary == null || empty($this->summary)) {
             $body = strip_tags($this->body);
             $pattern = '/\\s/';
             //去除空白
             $body = preg_replace($pattern, '', $body);
             $this->summary = TStringHelper::subStr($body, 250);
         }
         return true;
     }
     return false;
 }
Example #5
0
	      <th width="150">操作</th>
	    </tr>
		<?php 
foreach ($rows as $row) {
    ?>
		<tr>
		<td><?php 
    echo $row['id'];
    ?>
</td>
		<td><?php 
    echo $row['title'];
    ?>
</td>
		<td><?php 
    echo TTimeHelper::showTime($row['publish_time']);
    ?>
</td>
		<td><?php 
    echo $row['sort_num'];
    ?>
</td>
		<td>
			<?php 
    echo Html::a('编辑', ['update', 'id' => $row->id]);
    ?>
			<?php 
    echo Html::a('删除', ['delete', 'id' => $row->id], ['data-confirm' => Yii::t('app', 'Are you sure to delete this item?'), 'data-method' => 'post']);
    ?>
		</td>
		</tr>
Example #6
0
<?php

use yii\helpers\Html;
use components\helpers\TTimeHelper;
use common\includes\UrlUtility;
?>
<li><?php 
echo UrlUtility::getContentLink($row, $length);
?>
<span class="time"><?php 
TTimeHelper::showTime($row['publish_time'], 'm-d');
?>
</span></li>
Example #7
0
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         if ($this->hasAttribute('sort_num')) {
             if ($this->sort_num == null || $this->sort_num == '') {
                 $this->sort_num = 0;
             }
         }
         if ($this->hasAttribute('publish_time')) {
             if ($this->publish_time == null || $this->publish_time == '') {
                 $this->publish_time = TTimeHelper::getCurrentTime();
             }
         }
         if ($this->hasAttribute('modify_time')) {
             if ($this->modify_time == null || $this->modify_time == '') {
                 $this->modify_time = TTimeHelper::getCurrentTime();
             }
         }
         return true;
     }
     return false;
 }