Exemplo n.º 1
0
 public function actions()
 {
     $chnid = LuLu::getGetValue('chnid');
     $channel = $this->getChannel($chnid);
     $table = CommonUtility::getCachedTable($channel['table']);
     return DefineTable::getBackActions($table);
 }
Exemplo n.º 2
0
 public function actionTpl()
 {
     $themes = CommonUtility::getFiles('themes', null, false);
     $locals = [];
     $locals['themes'] = $themes;
     return $this->render('tpl', $locals);
 }
Exemplo n.º 3
0
 private function getDetailTpl($tpl)
 {
     $tplPath = CommonUtility::getThemePath(['page', $tpl]);
     if (TFileHelper::exist($tplPath)) {
         return $tpl;
     }
     return 'detail_default';
 }
Exemplo n.º 4
0
 public function init()
 {
     parent::init();
     if ($this->channels == null) {
         $this->channels = CommonUtility::getCachedChannel();
     }
     if ($this->rootChannels == null) {
         $this->rootChannels = CommonUtility::getRootChannels();
     }
 }
Exemplo n.º 5
0
 public function setTitle($title, $append = true)
 {
     $this->title = $title;
     if ($append == true) {
         $this->title .= '——' . CommonUtility::getCachedConfigValue('site_name');
     } else {
         if (is_string($append)) {
             $this->title .= $append;
         }
     }
 }
Exemplo n.º 6
0
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         $this->title_format = CommonUtility::getTitleFormatValue($this->title_format);
         $uploadedFile = CommonUtility::uploadFile('Fragment2Data[title_pic]');
         if ($uploadedFile != null) {
             $this->title_pic = $uploadedFile['url'] . $uploadedFile['new_name'];
         }
         return true;
     }
     return false;
 }
Exemplo n.º 7
0
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         $locals = [];
         $locals['model'] = $model;
         $locals['catid'] = $model->category_id;
         $locals['categories'] = PageCategory::getAllCategories();
         $locals['tpls'] = CommonUtility::getFrontViews('page', 'detail_');
         return $this->render('update', $locals);
     }
 }
Exemplo n.º 8
0
 private function getTpl($prefix)
 {
     $ret = [];
     $fiels = CommonUtility::getFrontViews(['content', 'model_default'], $prefix);
     foreach ($fiels as $file) {
         $ret[] = ['name' => $file, 'table' => '默认模板(model_default)'];
     }
     $tables = DefineTable::getAllTables();
     foreach ($tables as $table) {
         $fiels = CommonUtility::getFrontViews(['content', $table['id']], $prefix);
         foreach ($fiels as $file) {
             $ret[] = ['name' => $file, 'table' => $table['name_cn'] . '(' . $table . ')'];
         }
     }
     return $ret;
 }
Exemplo n.º 9
0
 public function getTpl($chnId, $tplType)
 {
     $ret = TFileHelper::buildPath(['model_default', str_replace('_tpl', '_default', $tplType)]);
     $cachedChannels = LuLu::getAppParam('cachedChannels');
     if (isset($cachedChannels[$chnId])) {
         $channelModel = $cachedChannels[$chnId];
         $table = $channelModel['table'];
         $tplName = $channelModel[$tplType];
         $tplPath = CommonUtility::getThemePath(['content', $table, $tplName]);
         if (TFileHelper::exist($tplPath)) {
             $ret = TFileHelper::buildPath([$table, $tplName]);
         } else {
             LuLu::info($tplPath . ' does not exist', __METHOD__);
         }
     }
     return $ret;
 }
Exemplo n.º 10
0
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load($_POST)) {
         $parentIds = Channel::getParentIds($model['parent_id']);
         if (in_array($model['id'], $parentIds)) {
             LuLu::setErrorMessage('不能设置父节点为当前节点的子节点');
             return $this->redirect(['update', 'id' => $id]);
         }
         $model->save();
         CacheUtility::createChannelCache();
         return $this->redirect(['index']);
     } else {
         $locals = [];
         $locals['model'] = $model;
         $locals['tableList'] = CommonUtility::getTables();
         $locals['channelTpls'] = $this->getTpl('channel_');
         $locals['listTpls'] = $this->getTpl('list_');
         $locals['detailTpls'] = $this->getTpl('detail_');
         return $this->render('update', $locals);
     }
 }
Exemplo n.º 11
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.º 12
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.º 13
0
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\includes\CommonUtility;
use yii\widgets\LinkPager;
/**
 * @var yii\web\View $this
 * @var yii\data\ActiveDataProvider $dataProvider
 * @var common\models\search\FragmentCategorySearch $searchModel
 */
$this->title = '碎片分类';
$this->addBreadcrumb(CommonUtility::getFragmentType($type) . '管理', ['fragment/index', 'type' => $type]);
$this->addBreadcrumb($this->title);
?>
<div class="fragment-category-index">
    <p>
        <?php 
echo Html::a('新建分类', ['create', 'type' => $type], ['class' => 'btn btn-success']);
?>
    </p>
	<table class="table">
	    <tr class="tb_header">
	      <th width="50">ID</th>
	      <th >分类名称</th>
	      <th width="80px">排序</th>
	      <th width="150">操作</th>
	    </tr>
		<?php 
foreach ($rows as $row) {
    ?>
Exemplo n.º 14
0
 private function setSeo()
 {
     $view = LuLu::getView();
     $title = CommonUtility::getCachedConfigValue('seo_title');
     if (empty($title)) {
         $title = '首页——' . CommonUtility::getCachedConfigValue('seo_name');
     }
     $view->setTitle($title);
     $view->registerMetaTag(['name' => 'keywords', 'content' => CommonUtility::getCachedConfigValue('seo_keywords')]);
     $view->registerMetaTag(['name' => 'description', 'content' => CommonUtility::getCachedConfigValue('seo_description')]);
 }
Exemplo n.º 15
0
<html lang="<?php 
echo Yii::$app->language;
?>
">
<head>
<meta charset="<?php 
echo Yii::$app->charset;
?>
" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>站点关闭——<?php 
echo CommonUtility::getConfigValue('site_name');
?>
</title>
</head>
<body>
	<div class="wrap">
		<div class="container" style="text-align: center; margin-top: 120px;">
			<h2>站点关闭</h2>
			<p>
				<?php 
echo CommonUtility::getConfigValue('site_status_message');
?>
			</p>
		</div>
	</div>

</body>
</html>

Exemplo n.º 16
0
	
	            <li><a href="2014-06/30/content_32807283.htm">湖北大冶液化气站发生爆燃 已造成8人受伤</a></li>
	
	            <li><a href="2014-06/30/content_32807212.htm">甘肃计划生育工作者不到岗长期在外打工被通报</a></li>
	
	            <li><a href="shehui/2014-06/30/content_32807637.htm">河南村民修下水道挖出三尊元末明初汉白玉雕像(图)</a></li>
	        </ul>
	    </div>
	    <div class="tbox border dot">
	        <div class="middleTitle3">
	            <h2><a href="node_7183298.htm" target="_blank" class="">最新更新</a></h2>
	        </div>
	        <ul class="txtContent">
	        	<?php 
$dataSource = DataSource::getContentByChannel($chnid, ['order' => 'publish_time desc']);
echo LoopData::widget(['dataSource' => $dataSource, 'params' => ['length' => 19]]);
?>
	        </ul>
	    </div>
	    <div class="tbox border">
	        
	        <div class="ad">
	        	<img alt="" src="<?php 
echo CommonUtility::getThemeUrl();
?>
/images/ad2.png">
	        </div>
	    </div>
	</div>
</div>
Exemplo n.º 17
0
<?php

use common\includes\CommonUtility;
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/vendor/yiisoft/yii2/Yii.php';
require __DIR__ . '/common/config/bootstrap.php';
require __DIR__ . '/frontend/config/bootstrap.php';
require __DIR__ . '/common/config/autoload.php';
$config = yii\helpers\ArrayHelper::merge(require __DIR__ . '/common/config/main.php', require __DIR__ . '/common/config/main-local.php', require __DIR__ . '/frontend/config/main.php', require __DIR__ . '/frontend/config/main-local.php');
$application = new yii\web\Application($config);
$application->language = 'zh-CN';
$siteStatus = CommonUtility::getCachedConfigValue('site_status');
if ($siteStatus === '0') {
    $application->catchAll = ['site/close', 'message' => 'test'];
}
$application->run();
Exemplo n.º 18
0
 public function init()
 {
     $this->baseUrl = '@web/static/themes/' . CommonUtility::getCurrentTheme();
     parent::init();
 }
Exemplo n.º 19
0
    <?php 
echo $form->field($model, 'id')->textInput(['maxlength' => 64]);
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => 64]);
?>

    <?php 
echo $form->field($model, 'value')->textarea(['rows' => 3]);
?>


    <?php 
echo $form->field($model, 'data_type')->dropDownList(CommonUtility::getDataType());
?>

    
    <?php 
echo $form->field($model, 'note')->textarea(['rows' => 3]);
?>
    
	
	<?php 
$this->echoButtons($model);
?>
	
	</table>
	
Exemplo n.º 20
0
		<div class="clear"></div>
		
		<?php 
echo $content;
?>
	
	</div>
	<div class="clear"></div>
	<footer class="footer">
		<div class="container">
		<p class="pull-left">&copy; My Company <?php 
echo date('Y');
?>
</p>
		<p class="pull-right"><?php 
echo Yii::powered();
?>
</p>
		</div>
	</footer>

	<?php 
echo CommonUtility::getConfigValue('site_stats');
?>
	<?php 
$this->endBody();
?>
</body>
</html>
<?php 
$this->endPage();
Exemplo n.º 21
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\includes\CommonUtility;
/**
 * @var yii\web\View $this
 * @var common\models\Fragment2Data $model
 * @var yii\widgets\ActiveForm $form
 */
$this->registerJsFile('static/common/js/common.js');
$formatArray = CommonUtility::getTitleFormat();
$formatValueArray = CommonUtility::getTitleFormatArray($model);
?>

<div class="fragment2-data-form">

    <?php 
$disabled = $model->isNewRecord ? null : 'disabled';
$form = ActiveForm::begin(['fieldConfig' => $this->getDefaultFieldConfig2(), 'options' => ['enctype' => 'multipart/form-data']]);
?>
	<table class="table">

    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => 120]);
?>

      <tr class="form-group field-fragment2data-title_format">
		<td class="hAlign_right padding_r10">
			<label style="font-weight:normal;" for="fragment2data-title_format">标题格式</label>:</td>
		<td>
Exemplo n.º 22
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\web\View;
use common\models\config\Config;
use common\includes\CommonUtility;
/**
 * @var yii\web\View $this
 * @var app\models\Content $model
 * @var yii\widgets\ActiveForm $form
 */
$this->registerJsFile('static/common/js/common.js');
$formatArray = CommonUtility::getTitleFormat();
$formatValueArray = CommonUtility::getTitleFormatArray($model);
$contentFlags = CommonUtility::getFlag();
$att1Lable = Config::getValue('content_att1_label', '属性1');
$att1Array = Config::getContentAtt('content_att1_name');
$att2Lable = Config::getValue('content_att2_label', '属性2');
$att2Array = Config::getContentAtt('content_att2_name');
$att3Lable = Config::getValue('content_att3_label', '属性3');
$att3Array = Config::getContentAtt('content_att3_name');
?>
    <input type="hidden" id="content-channel_id" class="form-control" name="Content[channel_id]" value="<?php 
echo $chnid;
?>
">
  
    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => 128]);
?>
Exemplo n.º 23
0
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'];
?>
</p>
</li>

Exemplo n.º 24
0
    ?>
		<tr>
		<td><?php 
    echo $row['id'];
    ?>
</td>
		<td><?php 
    echo $row['name'];
    ?>
</td>
		<td><?php 
    echo $row['value'];
    ?>
</td>
		<td><?php 
    echo CommonUtility::getDataType($row['data_type']);
    ?>
</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>
		<?php 
}
?>
	</table>
Exemplo n.º 25
0
    ?>
</td>
		<td><?php 
    echo $row['field_name'];
    ?>
</td>
		<td><?php 
    echo $row['fieldtype'];
    ?>
</td>
		<td><?php 
    echo CommonUtility::getYesNo($row['is_null']);
    ?>
</td>
		<td><?php 
    echo CommonUtility::getYesNo($row['is_main']);
    ?>
</td>
		<td>
		<?php 
    echo Html::a('编辑', ['update', 'tb' => $row->table, 'id' => $row->id]);
    ?>
		<?php 
    if (!$row['is_sys']) {
        echo Html::a('删除', ['delete', 'tb' => $row->table, 'id' => $row->id], ['data-confirm' => Yii::t('app', 'Are you sure to delete this item?'), 'data-method' => 'post']);
    }
    ?>
	
		</td>
		</tr>
		<?php 
Exemplo n.º 26
0
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\includes\CommonUtility;
use yii\widgets\LinkPager;
/**
 * @var yii\web\View $this
 * @var yii\data\ActiveDataProvider $dataProvider
 * @var common\models\search\FragmentSearch $searchModel
 */
$this->title = CommonUtility::getFragmentType($type) . '管理';
$this->addBreadcrumb($this->title);
?>
<div class="fragment-index">

    <p>
        <?php 
echo Html::a('新建碎片', ['create', 'type' => $type], ['class' => 'btn btn-success']);
?>
        <?php 
echo Html::a('碎片分类', ['fragment-category/index', 'type' => $type], ['class' => 'btn btn-success']);
?>
    </p>
	<table class="table">
	    <tr class="tb_header">
	      <th width="50">ID</th>
	      <th >碎片名称</th>
	      <th width="120px">分类</th>
	      <th width="80px">排序</th>
	      <th width="150px">操作</th>
Exemplo n.º 27
0
        echo 'checked';
    }
    ?>
><?php 
    echo $flag['name'];
    ?>
</label>
			<?php 
}
?>
		</td>
		<td><div class="help-block"></div></td>
	</tr>

    <?php 
echo $form->field($model, 'status')->dropDownList(CommonUtility::getStatus());
?>

    <tr class="form-group field-content-title_pic">
		<td class="hAlign_right padding_r10" >
			<label style="font-weight:normal;" for="content-title_pic">标题图片</label>:</td>
		<td>
			<div class="file-box">
			<input type="text" id="content-title_pic" class="form-control" style="display: inline-block; width:500px; " name="Content[title_pic]" value="<?php 
echo $model['title_pic'];
?>
" maxlength="128">
			<input type='button' class='form-control' style="display: inline-block;width:60px;" value='浏览...' /> 
			<input type="file" name="Content[title_pic]" class="form-control file" onchange="document.getElementById('content-title_pic').value=getPath(this);" /> 
			</div>
		</td>
Exemplo n.º 28
0
 public static function buildContentQuery($tableName, $other = [], $where = null)
 {
     $query = new Query();
     if (isset($other['fields'])) {
         $query->select($other['fields']);
     }
     if (empty($tableName)) {
         // todo
         $tableName = 'model_news';
     }
     $query->from($tableName);
     if ($where !== null) {
         $query->andWhere($where);
     }
     if (isset($other['where'])) {
         $query->andWhere($other['where']);
     }
     if (isset($other['att1']) && is_integer($other['att1'])) {
         $query->andWhere(['att1' => $other['att1']]);
     }
     if (isset($other['att2']) && is_integer($other['att2'])) {
         $query->andWhere(['att2' => $other['att2']]);
     }
     if (isset($other['att3']) && is_integer($other['att3'])) {
         $query->andWhere(['att3' => $other['att3']]);
     }
     if (isset($other['flag'])) {
         $flagValue = CommonUtility::getFlagValue($other['flag']);
         if ($flagValue > 0) {
             $query->andWhere('flag&' . $flagValue . '>0');
         }
     }
     if (isset($other['is_pic']) && $other['is_pic']) {
         $query->andWhere(['is_pic' => 1]);
     }
     if (isset($other['order'])) {
         $query->orderBy($other['order']);
     } else {
         $query->orderBy('publish_time desc');
     }
     if (isset($other['offset'])) {
         $query->offset(intval($other['offset']));
     } else {
         $query->offset(0);
     }
     if (isset($other['limit'])) {
         $query->limit(intval($other['limit']));
     } else {
         $query->limit(10);
     }
     return $query;
 }