Exemplo n.º 1
0
 /**
  * Lists all Nav models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Nav::find()->alive(), 'pagination' => ['pageSize' => static::MAX_PAGE_SIZE], 'sort' => ['defaultOrder' => ['order' => SORT_ASC]]]);
     //递归处理
     $dataProvider->models = General::recursiveObj($dataProvider->models, 0, 0, '', '<span class="bank"></span>', false);
     //     	$keys = General::getModelsKeys($dataProvider->models, 'id');
     //     	$dataProvider->setKeys($keys);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
Exemplo n.º 2
0
 public function init()
 {
     //仅删除图片操作
     if (Yii::$app->getRequest()->get('action', '') == 'del') {
         if (Yii::$app->getRequest()->get('filename', false)) {
             $fileName = Yii::$app->getRequest()->get('filename');
             $path = Yii::getAlias('@webroot') . $fileName;
             if (is_file($path) && unlink($path)) {
                 @unlink(str_replace('origin/', '', $path));
                 //尝试删除缓存
                 Json::encode(['status' => 0, 'msg' => Yii::t('uploadify', 'Delete File Success')]);
             }
         }
         Yii::$app->end();
     }
     if (Yii::$app->getRequest()->isPost) {
         $this->initCsrf();
         //临时关闭csrf并校验session id(客户端组件不支持)
         //风险控制
         switch (false) {
             case $this->checkTimeOut():
                 echo Yii::t('uploadify', 'Upload timeout,Please refresh Page!');
                 break;
             case $this->checkSalt():
                 echo Yii::t('uploadify', 'Salt no pass,Invalid Data!');
                 break;
             case $this->checkSession():
                 echo Yii::t('uploadify', 'Session no pass,Invalid Data!');
                 break;
             default:
                 //开始上传
                 //Yii::$app->getRequest()->post('iswatermark')//水印
                 $file = UploadedFile::getInstanceByName($this->fileData);
                 //uploadify一个一个请求,一次返回的一个文件
                 $result = General::uploadToWebFilePath([$file], Yii::$app->getRequest()->post('dir'));
                 //                     $this->log($result);exit;
                 if (!empty($result['error'])) {
                     echo $result['error'];
                     //Json::encode(['status'=>0, 'msg'=>$result['error']]);
                 } else {
                     echo str_replace('\\', '/', $result[0]);
                     //调试
                     //                         $this->log($pathInfo);
                 }
                 //                     echo $pathInfo;
                 //Json::encode(['status'=>0, 'msg'=>$pathInfo]);
         }
         Yii::$app->end();
     }
     parent::init();
 }
Exemplo n.º 3
0
 /**
  * Updates an existing Customer model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     //$model = (new Customer(['scenario' => 'update']))->findOne($id);
     $model = $this->findModel($id);
     $model->setScenario('update');
     if (Yii::$app->request->post()) {
         //时间转化
         $post = General::dateTimeAsInt(Yii::$app->request->post(), 'Customer', ['birthday']);
         if ($model->load($post) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         }
     }
     return $this->render('update', ['model' => $model]);
 }
Exemplo n.º 4
0
 public function run()
 {
     $uploadPath = Yii::getAlias('@backend') . '/web/upload';
     $model = Ad::findOne(['short_code' => $this->short_code]);
     if ($model && is_file($uploadPath . '/' . $model->pic_url)) {
         list($width, $height, $type, $attr) = getimagesize($uploadPath . '/' . $model->pic_url);
         if ($this->height && $this->width) {
             //nothing
         } elseif ($this->height) {
             $this->width = floor($this->height * $width / $height);
         } elseif ($this->width) {
             $this->height = floor($this->width * $height / $width);
         }
         $img = General::showImg($model->pic_url, 'c', $model->title, 'px', $this->width, $this->height);
         return $this->render('side-ad', ['model' => $model, 'img' => $img]);
     } else {
         return '';
     }
 }
Exemplo n.º 5
0
?>
        
        <?php 
echo $form->field($model, 'mode')->dropDownList(Ad::getAdMode());
?>

	    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>
	    
	    <?php 
echo $form->field($model, 'short_code')->textInput(['maxlength' => true]);
?>
	    
	    <?php 
echo $form->field($model, 'pic_url')->hint('<i class="fa fa-info-circle"></i> ' . Yii::t('fileinput', 'Note: Limit upload one picture.'))->widget(FileInput::classname(), ['options' => ['accept' => 'image/*', 'multiple' => false], 'pluginOptions' => ['uploadUrl' => Url::to(['/cms/ad/file-upload']), 'uploadAsync' => true, 'initialPreview' => General::showImages($model->pic_url), 'initialPreviewConfig' => General::showLinks($model->pic_url, 'pic_url', 'ad', '/cms/ad/file-upload'), 'previewFileType' => 'any', 'overwriteInitial' => true, 'maxFileSize' => Yii::$app->params['config']['config_pic_size'], 'allowedFileExtensions' => explode(',', Yii::$app->params['config']['config_pic_extension']), 'allowedFileTypes' => ['image'], 'maxFileCount' => 1, 'uploadExtraData' => ['dir' => 'ad', 'name' => 'Ad[pic_url]', 'route' => '/cms/ad/file-upload', 'field' => 'pic_url']]]);
?>
	    
	    <?php 
/*
	    FileInput::widget([
	    	'name' => 'pic_url',
	    	'options'=>[
	    		'accept' => 'image/*',//只接收图片类型
	    		'multiple'=>false,//这里不需要多选
	    	],
	    	'pluginOptions' => [
	    		'uploadUrl' => Url::to(['/cms/ad/file-upload']),
// 	    		'uploadAsync' => true,//异步上传
	    		'initialPreview'=>[
	    			//Html::img("/images/moon.jpg", ['class'=>'file-preview-image', 'alt'=>'The Moon', 'title'=>'The Moon']),
Exemplo n.º 6
0
?>

<?php 
//$model, $key, $index, $widget
//Html::encode($model->title)
$length = 28;
//标题截取长度
$dlength = 82;
?>

<div class="list">
	<?php 
//这里可以考虑从content中获取图片
?>
    <?php 
echo Html::a(General::showImg($model->pic_url, 'c', $model->title, 'px', 140, 102), ['/site/post/view', 'id' => $model->id], ['class' => 'img', 'title' => $model->title]);
?>
    <div class="list_detail">
    	<?php 
$options = ['style' => ''];
if (!empty($model->colorval) || !empty($model->boldval)) {
    Html::addCssStyle($options, ['color' => $model->colorval, 'font-weight' => $model->boldval]);
}
?>
    	<?php 
echo Html::a(StringHelper::truncate($model->title, $length), ['/site/post/view', 'id' => $model->id], ['class' => 'title', 'title' => $model->title, 'style' => $options['style']]);
?>
        
        <div class="cont">
        	<?php 
if (empty($model->description)) {
Exemplo n.º 7
0
use common\helpers\General;
use common\models\catalog\Category;
use common\models\catalog\Brand;
use backend\assets\DatePickerAsset;
/* @var $this yii\web\View */
/* @var $model common\models\catalog\Product */
/* @var $form yii\widgets\ActiveForm */
//加载一插件
DatePickerAsset::register($this);
//使用插件
$this->registerJs("\n\t\$('#product-promote_start_date, #product-promote_end_date').datepicker({\n        language: '" . Yii::$app->language . "',//使用当前语言\n\t    format: 'yyyy/mm/dd'\n\t});\n");
$model->promote_start_date = Yii::$app->getFormatter()->asDate($model->promote_start_date, 'yyyy/MM/dd');
//与js配合
$model->promote_end_date = Yii::$app->getFormatter()->asDate($model->promote_end_date, 'yyyy/MM/dd');
//与js配合
$cateList = ArrayHelper::map(General::recursiveObj(Category::find()->orderBy(['sort' => SORT_ASC])->all()), 'id', 'name');
$brandList = ArrayHelper::map(Brand::find()->orderBy(['sort' => SORT_ASC])->all(), 'id', 'name');
?>

<!-- 导航 -->
<div id="product_nav">
    <ul>
        <li><a href="#home"><?php 
echo Yii::t('catalog', 'Base');
?>
</a></li>
        <li><a href="#declare"><?php 
echo Yii::t('catalog', 'Declare');
?>
</a></li>
        <li><a href="#price"><?php 
Exemplo n.º 8
0
                <div class="tab-pane active category-index">
                
                <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>
                        
                    <!-- 
                        <p>
                            <?php 
echo Html::a(Yii::t('catalog', 'Create Category'), ['create'], ['class' => 'btn btn-success']);
?>
                        </p>
                     -->
            
                <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'options' => ['class' => 'grid-view box-body table-responsive no-padding'], 'tableOptions' => ['class' => 'table table-hover table-striped table-bordered'], 'headerRowOptions' => [], 'footerRowOptions' => [], 'showHeader' => true, 'showFooter' => false, 'layout' => "{summary}\n{errors}\n{items}\n{pager}", 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'name', ['attribute' => 'parent_id', 'filter' => ArrayHelper::merge([0 => Yii::t('catalog', 'Top Category')], ArrayHelper::map(General::recursiveObj(Category::find()->orderBy(['sort' => SORT_ASC])->all()), 'id', 'name')), 'value' => function ($model, $key, $index, $_this) {
    if (!$model->parent_id) {
        return Yii::t('catalog', 'Top Category');
    } else {
        return $model->getRelatedRecords()['mySelf']->name;
    }
}], ['attribute' => 'top', 'filter' => [Category::CATEGORY_IS_TOP => Yii::t('catalog', 'Is Top'), Category::CATEGORY_NOT_TOP => Yii::t('catalog', 'Not Top')], 'value' => function ($model, $key, $index, $_this) {
    return $model->top ? Yii::t('catalog', 'Is Top') : Yii::t('catalog', 'Not Top');
}], ['attribute' => 'status', 'filter' => [Category::CATEGORY_STATUS_ON => Yii::t('catalog', 'Status On'), Category::CATEGORY_STATUS_OFF => Yii::t('catalog', 'Status Off')], 'value' => function ($model, $key, $index, $_this) {
    return $model->status ? Yii::t('catalog', 'Status On') : Yii::t('catalog', 'Status Off');
}], ['attribute' => 'sort', 'filter' => false], ['attribute' => 'updated_at', 'format' => 'datetime', 'filter' => false], ['class' => 'yii\\grid\\ActionColumn', 'header' => Yii::t('common', 'Opration')]]]);
?>
                                
                </div>
                
            </div>
Exemplo n.º 9
0
            <div class="tab-content clearfix">
                <div class="tab-pane active product-index">
                    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>
                    <!-- 
                        <p>
                            <?php 
echo Html::a(Yii::t('catalog', 'Create Product'), ['create'], ['class' => 'btn btn-success']);
?>
                        </p>
                     -->
                    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'options' => ['class' => 'grid-view box-body table-responsive no-padding'], 'tableOptions' => ['class' => 'table table-hover table-striped table-bordered'], 'headerRowOptions' => [], 'footerRowOptions' => [], 'showHeader' => true, 'showFooter' => false, 'layout' => "{summary}\n{errors}\n{items}\n{pager}", 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'name', 'shop_price:currency', 'sku', ['attribute' => 'category_id', 'value' => function ($model, $key, $index, $_this) {
    return $model->getRelatedRecords()['category']->name;
}, 'filter' => ArrayHelper::map(General::recursiveObj(Category::find()->orderBy(['sort' => SORT_ASC])->all()), 'id', 'name')], ['header' => Yii::t('catalog', 'Shortcut'), 'format' => 'raw', 'value' => function ($model, $key, $index, $_this) {
    $str = '';
    //$str .= '<a href="javascript:;" title="'.Yii::t('catalog', 'Is Del').'" data-id="'.$model->id.'" data-status="'.$model->is_del.'"><span class="label label-'.($model->is_del?'danger':'success').'">&nbsp;</span></a> ';
    $str .= '<a href="javascript:;" data-original-title="' . Yii::t('catalog', 'Is Promote') . '" data-toggle="tooltip" data-id="' . $model->id . '" data-status="' . $model->is_promote . '"><span class="label label-' . ($model->is_promote ? 'success' : 'danger') . '">&nbsp;</span></a> ';
    $str .= '<a href="javascript:;" data-original-title="' . Yii::t('catalog', 'Is Hot') . '" data-toggle="tooltip" data-id="' . $model->id . '" data-status="' . $model->is_hot . '"><span class="label label-' . ($model->is_hot ? 'success' : 'danger') . '">&nbsp;</span></a> ';
    $str .= '<a href="javascript:;" data-original-title="' . Yii::t('catalog', 'Is New') . '" data-toggle="tooltip" data-id="' . $model->id . '" data-status="' . $model->is_new . '"><span class="label label-' . ($model->is_new ? 'success' : 'danger') . '">&nbsp;</span></a> ';
    $str .= '<a href="javascript:;" data-original-title="' . Yii::t('catalog', 'Is Best') . '" data-toggle="tooltip" data-id="' . $model->id . '" data-status="' . $model->is_best . '"><span class="label label-' . ($model->is_best ? 'success' : 'danger') . '">&nbsp;</span></a> ';
    $str .= '<a href="javascript:;" data-original-title="' . Yii::t('catalog', 'Is Free Shipping') . '" data-toggle="tooltip" data-id="' . $model->id . '" data-status="' . $model->is_free_shipping . '"><span class="label label-' . ($model->is_free_shipping ? 'success' : 'danger') . '">&nbsp;</span></a> ';
    return $str;
}], 'date_available:datetime', 'updated_at:datetime', ['attribute' => 'status', 'format' => 'html', 'value' => function ($model, $key, $index, $_this) {
    return '<span class="label label-' . ($model->status ? 'success' : 'danger') . '">&nbsp;</span>';
}, 'filter' => [Product::PRODUCT_STATUS_ON => Yii::t('catalog', 'Status On'), Product::PRODUCT_STATUS_OFF => Yii::t('catalog', 'Status Off')]], ['class' => 'yii\\grid\\ActionColumn', 'header' => Yii::t('common', 'Opration')]]]);
?>
                                
                </div>
                
Exemplo n.º 10
0
	    <a href="javascript:void(0)" class="prev"></a>
	    <a href="javascript:void(0)" class="next"></a>
        <ul>
        	<?php 
foreach ($scenes as $scene) {
    ?>
            <li>
            	<?php 
    $link = $scene->link_url;
    if (empty($link)) {
        $link = ['/site/pic/view', 'name' => '', 'id' => $scene->id];
    }
    ?>
            	<?php 
    echo Html::a('<span class="pic_box">' . General::showImg($scene->pic_url, 'o', $scene->title, 'px', '230', '140') . '</span><span class="text-box">' . $scene->title . '</span>', $link);
    ?>
            </li>
            <?php 
}
?>
        </ul>
    </div>
</div>

<div id="index_banner_botton">
	<?php 
echo Html::a(General::showImg($adBottom->pic_url, 'o', $adBottom->title, 'px', '1024', '95', 'w'), ['/ad/link/ad-click', 'name' => $adBottom->short_code], ['target' => '_blank']);
?>
</div>

Exemplo n.º 11
0
				</div>
		    </div>
		</div>
	</div>
	
	<div class="black-foot footer">
		
		<div class="footer_bottom_container">
		    <div class="fbc_menu">
		        <ul>
		        <?php 
$subMenus = (new Nav())->TgetNav('sub-main');
$count = count($subMenus);
fb($count);
foreach ($subMenus as $key => $menu) {
    $url = empty($menu->re_link_url) ? General::parseUrl($menu->link_url) : $menu->re_link_url;
    ?>
		        	<li>
		        	<?php 
    echo Html::a($menu->name, $url);
    ?>
		        	<?php 
    echo $count == $key + 1 ? '' : '<span></span>';
    ?>
		            </li>
		        <?php 
}
?>
		        </ul>
		    </div>
		</div>
Exemplo n.º 12
0
use yii\helpers\Html;
//use yii\widgets\ActiveForm;
use yii\bootstrap\ActiveForm;
use yii\helpers\ArrayHelper;
use common\helpers\General;
use common\models\catalog\Category;
use backend\components\uploadify\UploadifyWidget;
use backend\components\ueditor\UeditorWidget;
/* @var $this yii\web\View */
/* @var $model common\models\catalog\Category */
/* @var $form yii\widgets\ActiveForm */
if ($model->isNewRecord) {
    $model->status = true;
}
$parentList = ArrayHelper::merge([0 => Yii::t('catalog', 'Top Category')], ArrayHelper::map(General::recursiveObj(Category::find()->orderBy(['sort' => SORT_ASC])->all()), 'id', 'name'));
?>

<div class="row category-form">
    <div class="col-md-1"></div>
    <div class="col-md-12 col-lg-6">
        <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>
        <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>
        <?php 
echo $form->field($model, 'parent_id')->dropDownList($parentList);
?>