Esempio n. 1
0
 public static function getSmallProductImage($model)
 {
     $image = Image::find()->where(['product_id' => $model->id])->one();
     if ($image) {
         /* @var $image \common\models\Image */
         return Html::img($image->getUrl(), ['alt' => 'image', 'style' => 'width: 75px;']);
     }
 }
Esempio n. 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Image::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'product_id' => $this->product_id]);
     return $dataProvider;
 }
Esempio n. 3
0
 public function actionViewbyslug($slug)
 {
     $this->layout = "main";
     $model = Product::find()->where(['product_slug' => $slug])->one();
     if (!$model) {
         throw new NotFoundHttpException('The requested page does not exist.');
     } else {
         $image = Image::find()->where(['product_id' => $model->product_id])->all();
         return $this->render('viewbyslug', ['model' => $model, 'image' => $image]);
     }
 }
Esempio n. 4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Image::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     //        if (!($this->load($params) && $this->validate())) {
     //            return $dataProvider;
     //        }
     if (empty($params) || !$this->validate()) {
         return $dataProvider;
     }
     $this->id = $params['id'];
     $query->andFilterWhere(['product_id' => $this->id]);
     return $dataProvider;
 }
Esempio n. 5
0
 /**
  * Creates data provider instance with search query applied
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Image::find();
     if (!isset($params['sort'])) {
         $query->orderBy(['file_time' => SORT_DESC]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 24], 'sort' => ['defaultOrder' => ['file_time' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'title', $this->fileTitle]);
     return $dataProvider;
 }
Esempio n. 6
0
 public function getAdi($condition)
 {
     return Image::find()->where($condition)->asArray()->one();
 }
Esempio n. 7
0
 /**
  * Save Article model
  * @param bool $insert
  */
 public function saveArticle($insert = true)
 {
     $article = $insert === true ? new Article() : Article::findOne($this->item_id);
     $imageId = null;
     if (!isset(Yii::$app->request->post('ArticleForm')['imageFilename'])) {
         $this->imageFilename = null;
     }
     if ($this->imageFilename) {
         $imageId = Image::find()->andWhere(['filename' => $this->getImageName()])->scalar();
     }
     $this->image_id = $imageId;
     $article->attributes = $this->toArray();
     if ($this->content_date) {
         $article->content_date = Yii::$app->formatter->asDate($this->content_date, 'y-MM-dd');
     }
     if ($this->content_end_date) {
         $article->content_end_date = Yii::$app->formatter->asDate($this->content_end_date, 'y-MM-dd');
     }
     if ($this->content_time) {
         $article->content_time = Yii::$app->formatter->asTime($this->content_time, 'HH:mm');
     }
     $article->active = is_array($this->boxes) && in_array(self::PROPERTY_ACTIVE, $this->boxes) ? 1 : 0;
     $article->public = is_array($this->boxes) && in_array(self::PROPERTY_PUBLIC, $this->boxes) ? 1 : 0;
     if ($this->item_id) {
         ArticleCategory::deleteAll(['article_id' => $this->item_id]);
     }
     $article->tagValues = $this->tagValues;
     $article->save(false);
     if (is_array($this->categoryBoxes)) {
         foreach ($this->categoryBoxes as $categoryBox) {
             $articleCategory = new ArticleCategory();
             $articleCategory->article_id = $article->id;
             $articleCategory->category_id = $categoryBox;
             $articleCategory->save();
         }
     }
 }
Esempio n. 8
0
 public function getImagesList()
 {
     $img = Image::find()->andWhere(['table_id' => $this->id])->andWhere(['table_name' => \common\functions\TableName::name($this)])->all();
     return ArrayHelper::map($img, 'id', 'id');
 }
Esempio n. 9
0
 public function actionUploaded()
 {
     if (!\Yii::$app->request->isAjax) {
         throw new BadRequestHttpException('Данный метод возможен только через ajax!');
     }
     \Yii::$app->response->format = 'json';
     $images = [];
     foreach (Image::find()->each() as $image) {
         $imageObj = new \stdClass();
         $imageObj->thumb = $image->link;
         $imageObj->image = $image->link;
         $imageObj->title = empty($image->description) ? '' : $image->description;
         $imageObj->id = "img{$image->id}";
         $images[] = $imageObj;
     }
     return $images;
 }
Esempio n. 10
0
 /**
  * Creates data provider instance
  * @return ActiveDataProvider
  */
 public function search()
 {
     $query = Image::find()->andWhere(['not in', 'id', $this->usedImagesIds]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['file_time' => SORT_DESC]], 'pagination' => ['pageSize' => 24]]);
     return $dataProvider;
 }
Esempio n. 11
0
 /**
  * Save Page model
  * @param bool $insert
  */
 public function savePage($insert = true)
 {
     $page = $insert === true ? new Page() : Page::findOne($this->item_id);
     $imageId = null;
     if (!isset(Yii::$app->request->post('PageForm')['imageFilename'])) {
         $this->imageFilename = null;
     }
     if ($this->imageFilename) {
         $imageId = Image::find()->andWhere(['filename' => $this->getImageName()])->scalar();
     }
     $this->image_id = $imageId;
     $page->attributes = $this->toArray();
     $page->active = is_array($this->boxes) && in_array(self::PROPERTY_ACTIVE, $this->boxes) ? 1 : 0;
     $page->public = is_array($this->boxes) && in_array(self::PROPERTY_PUBLIC, $this->boxes) ? 1 : 0;
     $page->tagValues = $this->tagValues;
     if ($page->save()) {
         $this->item_id = $page->id;
     }
 }
Esempio n. 12
0
 /**
  * 根据疾病id, 查询相关图集信息
  * @author gaoqing
  * 2016年1月19日
  * @param int $diseaseid 疾病id
  * @return array 图集信息
  */
 public function getImagesByDiseaseid($diseaseid)
 {
     $image = [];
     $image = Image::find()->asArray()->select(["id", "name", "weight", "flag"])->where("flag = :flag AND relid = :relid", [":flag" => 1, ":relid" => $diseaseid])->all();
     return $image;
 }
Esempio n. 13
0
<?php

use yii\helpers\Html;
use common\models\Image;
$image = Image::find()->where(['product_id' => $model->product_id])->one();
?>

<div class="col-md-3 productbox">

	<div class="inner-box">

		<?php 
echo Html::img("/advanced2/" . substr($image->image_url, 24), ['class' => 'main-product-image']);
?>
		<h5><?php 
echo Html::encode($model->product_name);
?>
</h5>
		<p>Rp. <?php 
echo Html::encode($model->product_price);
?>
</p>
		<?php 
echo Html::a('View', ['customer/viewbyslug', 'slug' => $model->product_slug], ['class' => 'btn btn-success tbl-beli']);
?>

	</div>
</div>

<?php 
$css = <<<CSS