Exemplo n.º 1
0
 public static function getPageLink($row, $length = 0, $options = [])
 {
     if (isset($options['title'])) {
         $title = $options['title'];
         unset($options['title']);
     } else {
         $title = $row['title'];
     }
     if (is_integer($length) && $length > 0) {
         $title = TStringHelper::subStr($title, $length);
     }
     $url = self::getPageUrl($row);
     return Html::a($title, $url, $options);
 }
Exemplo n.º 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 = 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();
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
    $hotContent = $channelHot[0];
    ?>
			<a href="<?php 
    echo UrlUtility::getContentUrl($hotContent);
    ?>
">
				<img src="<?php 
    echo CommonUtility::getTitlePic($hotContent);
    ?>
" style="width:380px;"></a>
			<h2><?php 
    echo UrlUtility::getContentLink($hotContent);
    ?>
</h2>
			<p style="width:260px;"><?php 
    echo TStringHelper::subStr($hotContent['summary'], 100);
    ?>
				<a href="<?php 
    echo UrlUtility::getContentUrl($hotContent);
    ?>
">[详细]</a></p>		
			<?php 
}
?>
		
		</div>
		<div class="clear"></div>
		<div class="content-channel">
			<?php 
echo LoopData::widget(['dataSource' => $dataList, 'item' => 'item-subchannel']);
?>
Exemplo n.º 5
0
<?php

use yii\helpers\Html;
use yii\helpers\Url;
use common\includes\UrlUtility;
use common\includes\CommonUtility;
use components\helpers\TStringHelper;
?>
<li>
<h4><a href="<?php 
echo $row['url'];
?>
"><?php 
echo TStringHelper::subStr($row['title'], $length);
?>
</a></h4>
<a href="<?php 
echo $row['url'];
?>
">
	<img src="<?php 
echo CommonUtility::getTitlePic($row);
?>
" border="0" alt="<?php 
echo $row['title'];
?>
" />
</a>
<p><?php 
echo $row['summary'];
?>