Esempio n. 1
0
 public function hoffmann($str, $fn)
 {
     //prepare search string
     $str = str_replace(' ', '-', $str);
     curl_setopt($this->ch, CURLOPT_URL, "https://www.hoffmann-group.com/US/en/hus/search?type=product&search=" . $str);
     $output = curl_exec($this->ch);
     $info = curl_getinfo($this->ch);
     $html = new HtmlDom();
     $html->load($output);
     $title = $html->find('title', 0);
     if ($title != null) {
         $title = strip_tags($title);
     }
     $imgs = $html->find('img[class=js-loupe]');
     $images = array();
     foreach ($imgs as $img) {
         array_push($images, basename($img->src));
         Picture::saveTempPicture($img->src);
     }
     $data = $html->find('img[class=img-nudge]', 0);
     if ($data != null) {
         $data = 'https://www.hoffmann-group.com' . $data->src;
         array_push($images, basename($data));
         Picture::saveTempPicture($data);
     }
     $result = array('images' => $images, 'title1' => $title, 'title2' => null, 'cuttingdata' => null, 'description' => $html->find('div[class=block-readable]', 0)->innertext, 'fn' => $fn);
     return $result;
 }
 public function actionLike()
 {
     if (!\Yii::$app->getRequest()->getIsPost()) {
         return 'try agaen';
     }
     if (\Yii::$app->getRequest()->getHeaders()->get('x-like') !== 'True') {
         return 'try agaen';
     }
     $pictureId = \Yii::$app->getRequest()->post('p');
     $hash = \Yii::$app->getRequest()->post('h');
     $picture = Picture::find()->where(['id' => $pictureId])->one();
     /* @var Picture $picture */
     if ($picture == null) {
         return 'try agaen';
     }
     if ($picture->getLikeHash() !== $hash) {
         return 'try agaen';
     }
     $like = Like::find()->where(['ip' => \Yii::$app->getRequest()->getUserIP(), 'pictureId' => $picture->getPrimaryKey()])->count();
     if ($like > 0) {
         return 'pls stap';
     }
     $like = new Like();
     $like->ip = \Yii::$app->getRequest()->getUserIP();
     $like->pictureId = $picture->getPrimaryKey();
     $like->save();
     $picture->likeCount += 1;
     $picture->save();
     return '+' . $picture->likeCount;
 }
 public function actionQueue()
 {
     $query = Picture::find()->where(['state' => 'new']);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 50]);
     $pages->pageSizeParam = false;
     $pictures = $query->offset($pages->offset)->limit($pages->limit)->orderBy('id asc')->all();
     return $this->render('queue', ['pictures' => $pictures, 'paginator' => $pages]);
 }
Esempio n. 4
0
 public function check()
 {
     $count = Picture::find()->where(['ip' => \Yii::$app->getRequest()->getUserIP()])->andWhere(['state' => 'new'])->count();
     if ($count >= 3) {
         $this->addError('image', 'Sorry, you cannot upload more than 3 images while they in queue. Try later.');
         return false;
     }
     return true;
 }
 public function actionClear()
 {
     $pictures = Picture::find()->where(['<=', 'updated', new Expression('NOW() - INTERVAL 5 MINUTE')])->andWhere(['state' => 'pending'])->all();
     /* @var Picture[] $pictures */
     foreach ($pictures as $pic) {
         echo "Pending picture #" . $pic->id . " was detached and become 'new' now.\n";
         $pic->state = 'new';
         $pic->save();
     }
     echo "Okay.\n";
 }
Esempio n. 6
0
 public function update($fieldsCols = null)
 {
     parent::update();
     $item = \app\models\Picture::find($this->id);
     $fields = [];
     if ($item->getField('description') == '') {
         $fields['description'] = GsssHtml::getMiniText($item->getField('content'));
     }
     if (count($fields) > 0) {
         $item->update($fields);
     }
     return true;
 }
Esempio n. 7
0
 /**
  * Save Images from temporary folder to Storage and store it in database
  *
  * @param Item		$item
  * @param Supplier	$supplier
  * @param array		$images
  *
  * @return
  */
 public static function saveImages($item, $supplier, $request)
 {
     // Get the short name of supplier
     $supplier = $supplier->shortname;
     $path = 'pictures/' . $supplier . '/';
     foreach ($request->images['image'] as $image) {
         $picture = Picture::where('path', '=', $path . $image)->first();
         $first_choice = $request->picture == $image ? 1 : 0;
         // If Picture exist in database, check if it's attached to this Item.
         // If Picture don't exist in database, create it and attach it to this Item.
         if ($picture === null) {
             $picture = new Picture(['path' => $path, 'title' => $image]);
             $picture->save();
             $picture->moveImage();
             $item->pictures()->attach($picture->id, ['first_choice' => $first_choice]);
         } elseif ($picture) {
             // If item don't have picture attached, attach it!
             if (!$item->hasPicture($picture->id)) {
                 $item->pictures()->attach($picture->id);
             }
         }
     }
 }
 public function up()
 {
     $algo = new \app\models\Algorithm();
     $algo->name = 'inception_4c/output';
     $algo->count = \app\models\Picture::find()->count();
     $algo->save();
     $pk = $algo->getPrimaryKey();
     \app\models\Picture::updateAll(['algorithm' => 'inception_4c/output', 'algorithmId' => $pk]);
     $other = ['conv2/3x3', 'conv2/3x3_reduce', 'conv2/norm2', 'inception_3a/3x3', 'inception_3a/3x3_reduce', 'inception_3a/5x5_reduce', 'inception_3a/output', 'inception_3a/pool', 'inception_3b/1x1', 'inception_3b/3x3', 'inception_3b/3x3_reduce', 'inception_3b/5x5_reduce', 'inception_3b/output', 'inception_3b/pool', 'inception_3b/pool_proj', 'inception_4a/1x1', 'inception_4a/3x3_reduce', 'inception_4a/5x5_reduce', 'inception_4b/pool'];
     foreach ($other as $name) {
         $algo = new \app\models\Algorithm();
         $algo->count = 0;
         $algo->name = $name;
         $algo->save();
     }
 }
Esempio n. 9
0
            <p class="text-center"><iframe width="100%" height="315" src="https://www.youtube.com/embed/-Z9PhUI5oUE" frameborder="0" allowfullscreen></iframe></p>

            <p class="text-center">Медитация Крыльев Ангела</p>
            <p class="text-center"><iframe allowfullscreen=""  frameborder="0" height="315" src="https://www.youtube.com/embed/P8ZDQ3fPVOA" width="100%"></iframe></p>

            <p class="text-center">Принцип работы тренажера Birdly®</p>
            <p class="text-center"><img src="/images/controller/site/media/11990631_10208204145722207_6888214533972897372_n.jpg" class="img-center" style="border-radius: 10px; width:100%;"></p>


            <p class="text-center">Изображения</p>
            <?php 
\app\assets\SlideShow\Asset::register($this);
?>
            <div class="row">
            <?php 
foreach (\app\models\Picture::query()->all() as $foto) {
    ?>
                <div class="col-sm-2">
                    <a href="<?php 
    echo \cs\Widget\FileUpload2\FileUpload::getOriginal($foto['image']);
    ?>
" rel="lightbox[example]" class="highslide" onclick="return hs.expand(this)">
                        <img src="<?php 
    echo $foto['image'];
    ?>
"  alt="<?php 
    echo $foto['name'];
    ?>
" width="100%" style="margin-bottom: 20px;">
                    </a>
                </div>
 protected function findModel($condition)
 {
     if (($model = Picture::findOne($condition)) !== null) {
         return $model;
     } else {
         $this->setHeader(400);
         echo json_encode(array('status' => 0, 'error_code' => 400, 'message' => 'Bad request'), JSON_PRETTY_PRINT);
         exit;
     }
 }
Esempio n. 11
0
 /**
  * Handle the deleting of a picture
  */
 public function postDelete($id)
 {
     // The picture we want to delete
     $picture = Picture::findOrFail($id);
     // Delete the picture in the db
     $picture->delete();
     if (file_exists(public_path('uploads/' . $picture->filename))) {
         // Delete the picture file
         unlink(public_path('uploads/' . $picture->filename));
     }
     // Return to the list of pictures
     return redirect('images');
 }
Esempio n. 12
0
 /**
  * Update inventory item
  * GET /inventory/(item)/save
  *
  * @param Request          $request
  * @param Inventory        $item
  *
  * @return
  */
 public function save(Request $request, Inventory $item)
 {
     $offset = count($request->category) - 1;
     /*
      * Set Category to NULL if requested category is 0
      */
     $category = $request->category[$offset];
     if ($category == 0 && $offset < 1) {
         $category = NULL;
     } elseif ($category == 0) {
         $category = $request->category[$offset - 1];
     }
     $item->serialnr = $request->serialnr;
     $item->name = $request->name;
     $item->brand_id = $request->brand_id;
     $item->category_id = $category;
     $item->save();
     $item->saveDetails($request);
     $supplier = Supplier::find($request->supplier_id);
     return Picture::saveImages($item, $supplier, $request);
     //$item->updateBarcode($request->barcode);
     //return $item;
 }
Esempio n. 13
0
    \$('.rowTable').click(function() {
        window.location = '/admin/pictures/' + \$(this).data('id');
    });


JS
);
?>

<div class="container">
    <h1 class="page-header">Картинки</h1>


    <?php 
echo \yii\grid\GridView::widget(['dataProvider' => new \yii\data\ActiveDataProvider(['query' => \app\models\Picture::query(), 'pagination' => ['pageSize' => 20]]), 'tableOptions' => ['class' => 'table table-hover table-striped'], 'rowOptions' => function ($item) {
    return ['role' => 'button', 'data-id' => $item['id'], 'class' => 'rowTable'];
}, 'columns' => ['id', ['header' => 'Картинка', 'content' => function ($item) {
    if (\yii\helpers\ArrayHelper::getValue($item, 'image', '') == '') {
        return '';
    }
    return Html::img($item['image'], ['width' => 50, 'class' => 'thumbnail', 'style' => 'margin-bottom: 0px;']);
}], 'name', ['header' => 'Удалить', 'content' => function ($item) {
    return Html::button('Удалить', ['class' => 'btn btn-danger btn-xs buttonDelete', 'data-id' => $item['id']]);
}]]]);
?>


    <div class="col-lg-6">
        <div class="row">
            <!-- Split button -->
Esempio n. 14
0
 public function actionStatus()
 {
     $pendingImageCount = Picture::find()->where(['state' => 'new'])->count();
     $pendingPictures = Picture::find()->where(['state' => 'pending'])->orderBy('id ASC')->all();
     $response = [];
     foreach ($pendingPictures as $pic) {
         $progress = (int) (100.0 * $pic->status / 40);
         $response[] = ['id' => $pic->id, 'source' => '/images/' . $pic->source, 'progress' => $progress];
     }
     echo json_encode(['images' => $response, 'queue' => $pendingImageCount]);
 }
Esempio n. 15
0
 public function getIndex()
 {
     $picturesCount = Picture::count();
     $tagsCount = Tag::count();
     return view('home', ['picturesCount' => $picturesCount, 'tagsCount' => $tagsCount]);
 }