public function up()
 {
     $all = \app\models\Chenneling::query(['description' => null])->all();
     foreach ($all as $item) {
         $i = new \app\models\Chenneling($item);
         $i->update(['description' => \app\services\GsssHtml::getMiniText($i->getField('content'))]);
     }
 }
示例#2
0
 public function insert($fieldsCols = NULL)
 {
     $extractorConfig = Collection::find($this->provider);
     if (is_null($extractorConfig)) {
         throw new Exception('Не верный extractor');
     }
     $extractorClass = $extractorConfig['class'];
     /** @var \app\services\GetArticle\ExtractorInterface $extractor */
     $extractor = new $extractorClass($this->url);
     $articleObject = Chenneling::insertExtractorInterface($extractor);
     $articleObject->update(['tree_node_id_mask' => (new BitMask($this->tree_node_id_mask))->getMask()]);
     return true;
 }
 public function actionIndex()
 {
     if (count(Yii::$app->request->post()) > 0) {
         $formValues = Yii::$app->request->post((new Investigator())->formName());
         $add = [];
         $skip = [];
         foreach ($formValues as $name => $value) {
             if (StringHelper::startsWith($name, 'id')) {
                 $id = substr($name, 2);
                 foreach (Yii::$app->session->get('items') as $sessionItem) {
                     if ($sessionItem['id'] == $id) {
                         switch ($value) {
                             // пропустить
                             case 1:
                                 $skip[] = $sessionItem['id'];
                                 break;
                                 // добавить
                             // добавить
                             case 2:
                                 $add[] = $sessionItem['id'];
                                 break;
                         }
                     }
                 }
             }
         }
         if (count($skip) > 0) {
             (new Query())->createCommand()->update(Inv::TABLE, ['status' => Inv::STATUS_SKIP], ['in', 'id', $skip])->execute();
         }
         foreach ($add as $item) {
             $i = Inv::find($item);
             $class = $i->getField('class_name');
             // послание
             /** @var \app\services\investigator\InvestigatorInterface $class */
             $class = new $class();
             $extractor = $class->getItem($i->getField('url'));
             // добавляю
             Chenneling::insertExtractorInterface($extractor);
         }
         if (count($add) > 0) {
             (new Query())->createCommand()->update(Inv::TABLE, ['status' => Inv::STATUS_ADD], ['in', 'id', $add])->execute();
         }
         Yii::$app->session->remove('items');
         Yii::$app->session->setFlash('contactFlash');
         return $this->render([]);
     } else {
         $items = \app\models\Investigator::query(['status' => \app\models\Investigator::STATUS_NEW])->select(['class_name as class', 'id', 'url', 'date_insert', 'status', 'name'])->all();
         Yii::$app->session->set('items', $items);
         return $this->render(['items' => $items]);
     }
 }
示例#4
0
 public function update($fieldsCols = null)
 {
     $fields = parent::update(['beforeUpdate' => function ($fields, \app\models\Form\Chenneling $model) {
         if ($fields['description'] == '') {
             $fields['description'] = GsssHtml::getMiniText($fields['content']);
         }
         return $fields;
     }]);
     $item = \app\models\Chenneling::find($this->id);
     if ($this->is_add_image) {
         $content = Html::tag('p', Html::img(\cs\Widget\FileUpload2\FileUpload::getOriginal($item->getField('img')), ['class' => 'thumbnail', 'style' => 'width:100%;', 'alt' => $item->getField('header')])) . $item->getField('content');
         $item->update(['content' => $content]);
     }
     return $fields;
 }
示例#5
0
<?php

use yii\helpers\Html;
use yii\bootstrap\ButtonDropdown;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $term string строка запроса */
$this->title = 'Результаты поиска';
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="container">

    <h1 class="page-header">Результаты поиска</h1>
    <?php 
echo \yii\grid\GridView::widget(['dataProvider' => new \yii\data\ActiveDataProvider(['query' => \app\models\Chenneling::query(['like', 'header', $term])->orWhere(['like', 'content', $term])->select('id, img, header, date, id_string')->orderBy(['date_insert' => SORT_DESC]), 'pagination' => ['pageSize' => 20]]), 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['header' => 'Картинка', 'content' => function ($model, $key, $index, $column) {
    return Html::a(Html::img($model['img'], ['width' => 40, 'class' => 'thumbnail', 'style' => 'margin-bottom: 0px;']), ['page/chenneling_item', 'year' => substr($model['date'], 0, 4), 'month' => substr($model['date'], 5, 2), 'day' => substr($model['date'], 8, 2), 'id' => $model['id_string']]);
}], ['header' => 'Название', 'content' => function ($model, $key, $index, $column) {
    return Html::a($model['header'], ['page/chenneling_item', 'year' => substr($model['date'], 0, 4), 'month' => substr($model['date'], 5, 2), 'day' => substr($model['date'], 8, 2), 'id' => $model['id_string']]);
}]]]);
?>
</div>
示例#6
0
 public function actionChenneling_ajax()
 {
     $itemsPerPage = $this->itemsPerPage;
     $cache = $this->renderFile('@app/views/page/chenneling_cache_list.php', $this->pageCluster(['query' => Chenneling::querylist()->orderBy(['date_insert' => SORT_DESC]), 'paginator' => ['size' => $itemsPerPage]]));
     return self::jsonSuccess($cache);
 }
示例#7
0
    ?>
                    <li><a href="<?php 
    echo Url::to(['admin/chenneling_list_add_from_page', 'page' => $item['name']]);
    ?>
">Добавить
                            с <?php 
    echo $item['title'];
    ?>
</a></li>
                <?php 
}
?>
            </ul>
        </div>
        <?php 
echo \yii\grid\GridView::widget(['dataProvider' => new \yii\data\ActiveDataProvider(['query' => \app\models\Chenneling::query()->orderBy(['date_insert' => SORT_DESC]), 'pagination' => ['pageSize' => 20]]), 'tableOptions' => ['class' => 'table table-striped table-hover'], 'rowOptions' => function ($item) {
    return ['data' => ['id' => $item['id']], 'role' => 'button', 'class' => 'rowTable'];
}, 'columns' => ['id', ['header' => 'Картинка', 'content' => function ($item) {
    $i = ArrayHelper::getValue($item, 'img', '');
    if ($i == '') {
        return '';
    }
    return Html::img($i, ['class' => "thumbnail", 'width' => 80]);
}], 'header:text:Название', ['header' => 'Дата', 'content' => function ($item) {
    return Html::tag('span', GsssHtml::dateString($item['date_insert']), ['style' => 'font-size: 80%; margin-bottom:10px; color: #c0c0c0;']);
}], ['header' => 'Удалить', 'content' => function ($item) {
    return Html::button('Удалить', ['class' => 'btn btn-danger btn-xs buttonDelete', 'data' => ['id' => $item['id']]]);
}], ['header' => 'Рассылка', 'content' => function ($item) {
    if (ArrayHelper::getValue($item, 'is_added_site_update', 0) == 1) {
        return '';
    }
示例#8
0
 public static function chennelingItem($row)
 {
     if (!is_array($row)) {
         $id = $row;
         $item = \app\models\Chenneling::find($id);
         if (is_null($item)) {
             return '';
         }
         $row = $item->getFields();
     }
     // Заголовок
     $html[] = Html::tag('div', Html::tag('h4', $row['header']), ['class' => 'header']);
     // Дата
     $html[] = Html::tag('p', self::dateString($row['date']), Html::css(['font-size' => '70%', 'color' => '#808080']));
     // картинка с ссылкой
     $year = substr($row['date'], 0, 4);
     $month = substr($row['date'], 5, 2);
     $day = substr($row['date'], 8, 2);
     $html[] = Html::tag('p', Html::a(Html::img($row['img'], ['width' => '100%', 'class' => 'thumbnail']), "/chenneling/{$year}/{$month}/{$day}/{$row['id_string']}"));
     // Описание
     $html[] = Html::tag('p', $row['description']);
     return Html::tag('div', join('', $html), ['class' => 'col-sm-4 chennelingItem']);
 }
示例#9
0
 public function actionChenneling_list_delete($id)
 {
     \app\models\Form\Chenneling::find($id)->delete();
     \app\models\Chenneling::clearCache();
     return self::jsonSuccess();
 }