示例#1
0
 public function insert()
 {
     /** @var \app\services\GetArticle\ExtractorInterface $extractor */
     $extractor = null;
     switch ($this->provider) {
         case 'verhosvet':
             $extractor = new \app\services\GetArticle\Verhosvet($this->url);
             break;
         case 'youtube':
             $extractor = new \app\services\GetArticle\YouTube($this->url);
             break;
     }
     if (is_null($extractor)) {
         throw new Exception('Не верный extractor');
     }
     $row = $extractor->extract();
     $articleObject = Article::insert(['header' => $row['header'], 'content' => $row['content'], 'description' => $row['description'], 'source' => $this->url, 'id_string' => Str::rus2translit($row['header']), 'date_insert' => gmdate('YmdHis'), 'tree_node_id_mask' => (new BitMask($this->tree_node_id_mask))->getMask()]);
     $this->id = $articleObject->getId();
     $image = $row['image'];
     $imageContent = file_get_contents($image);
     $imageUrl = parse_url($image);
     $pathInfo = pathinfo($imageUrl['path']);
     $pathInfo['extension'];
     $fields = \cs\Widget\FileUpload2\FileUpload::save(File::content($imageContent), $pathInfo['extension'], ['image', 'Картинка', 0, 'string', 'widget' => [FileUpload::className(), ['options' => ['small' => \app\services\GsssHtml::$formatIcon]]]], $this);
     $articleObject->update($fields);
     return true;
 }
示例#2
0
 public function insert($fieldsCols = null)
 {
     return parent::insert(['beforeInsert' => function ($fields) {
         $fields['date_insert'] = gmdate('YmdHis');
         $fields['id_string'] = Str::rus2translit($fields['header']);
         return $fields;
     }]);
 }
 public function up()
 {
     $this->execute('ALTER TABLE galaxysss_1.gs_unions_office ADD category VARCHAR(100) NULL;');
     $path = Yii::getAlias('@app/app/assets/1.xml');
     $data = file_get_contents($path);
     $x = new \DOMDocument();
     $x->loadXML($data);
     $ret = [];
     /** @var \DOMElement $element */
     foreach ($x->documentElement->childNodes as $element) {
         if ($element instanceof \DOMElement) {
             $data = $element->getAttribute('data-jmapping');
             $pos = Str::pos('lat', $data);
             $pos1 = Str::pos('lng', $data);
             $lat = Str::sub($data, $pos + 5, $pos1 - $pos - 7);
             $pos = Str::pos('lng', $data);
             $pos1 = Str::pos('category', $data);
             $lng = Str::sub($data, $pos + 5, $pos1 - $pos - 8);
             $pos = Str::pos('category', $data);
             $category = Str::sub($data, $pos + 11);
             $category = Str::sub($category, 0, Str::length($category) - 2);
             $category = explode('|', $category);
             $list = $element->getElementsByTagName("p");
             if ($list->length == 1) {
                 /** @var \DOMElement $content */
                 $content = $list->item(0);
                 $content = $x->saveXML($content);
                 $content = Str::sub($content, 3);
                 $content = Str::sub($content, 0, Str::length($content) - 4);
                 $content = explode('<br/>', $content);
                 $ret2 = [];
                 foreach ($content as $item) {
                     if (StringHelper::startsWith($item, '<b>')) {
                         $item = Str::sub($item, 3);
                         $item = Str::sub($item, 0, Str::length($item) - 4);
                     }
                     $ret2[] = trim($item);
                 }
                 $name = $ret2[0];
                 array_shift($ret2);
                 if (StringHelper::startsWith($ret2[count($ret2) - 1], 'Открытие')) {
                     $ret2 = array_reverse($ret2);
                     array_shift($ret2);
                     $ret2 = array_reverse($ret2);
                 }
                 if (StringHelper::startsWith($ret2[count($ret2) - 1], '"ВкусВилл')) {
                     $ret2 = array_reverse($ret2);
                     array_shift($ret2);
                     $ret2 = array_reverse($ret2);
                 }
                 $address = $ret2[0];
                 array_shift($ret2);
                 $ret[] = [392, $address, $name, $lat, $lng, join('|', $category), Html::tag('p', join('<br/>', $ret2))];
             }
         }
     }
     $this->batchInsert('gs_unions_office', ['union_id', 'point_address', 'name', 'point_lat', 'point_lng', 'category', 'content'], $ret);
 }
示例#4
0
 /**
  * Возвращает название статьи
  *
  * @return string
  */
 public function getHeader()
 {
     $h4 = $this->getDocument()->find('div.rt-article/.module-content/h4')[0];
     $name = $h4->plaintext;
     if (Str::sub($name, 0, 1) == '«') {
         $name = Str::sub($name, 1);
     }
     if (Str::sub($name, Str::length($name) - 1, 1) == '»') {
         $name = Str::sub($name, 0, Str::length($name) - 1);
     }
     $name = Str::sub($name, 0, 1) . Str::toLower(Str::sub($name, 1));
     return $name;
 }
示例#5
0
 /**
  * Преобразовывает текст в HTML
  * Если в передаваемом параметре есть уже HTML то он не будет обработан
  *
  * @param string $content
  *
  * @return string
  */
 public static function convertPlainTextToHtml($content)
 {
     if (Str::pos('<', $content) === false) {
         $rows = explode("\r", $content);
         $rows2 = [];
         foreach ($rows as $row) {
             if (trim($row) != '') {
                 $rows2[] = Html::tag('p', trim($row));
             }
         }
         return join("\r\r", $rows2);
     }
     return $content;
 }
示例#6
0
 public function insert($fieldsCols = null)
 {
     $row = parent::insert(['beforeInsert' => function ($fields) {
         $fields['date_insert'] = time();
         $fields['id_string'] = Str::rus2translit($fields['header']);
         return $fields;
     }]);
     $item = new \app\models\Service($row);
     $fields = [];
     if ($row['description'] == '') {
         $fields['description'] = GsssHtml::getMiniText($row['content']);
     }
     $item->update($fields);
     return $item;
 }
示例#7
0
 public function update($fieldsCols = null)
 {
     return parent::update(['beforeUpdate' => function ($fields) {
         if (Str::pos('<', $fields['content']) === false) {
             $rows = explode("\r", $fields['content']);
             $rows2 = [];
             foreach ($rows as $row) {
                 if (trim($row) != '') {
                     $rows2[] = Html::tag('p', trim($row));
                 }
             }
             $fields['content'] = join("\r\r", $rows2);
         }
         return $fields;
     }]);
 }
示例#8
0
 public function insert($fieldsCols = null)
 {
     $row = parent::insert(['beforeInsert' => function ($fields) {
         $fields['date_insert'] = gmdate('YmdHis');
         $fields['id_string'] = Str::rus2translit($fields['header']);
         return $fields;
     }]);
     $item = \app\models\Article::find($row['id']);
     $fields = [];
     if ($item->getField('description') == '') {
         $fields['description'] = GsssHtml::getMiniText($item->getField('content'));
     }
     if (count($fields) > 0) {
         $item->update($fields);
     }
     return $item;
 }
示例#9
0
 /**
  * Возвращает массив чистых строк без тегов
  *
  * @return array
  */
 public function getContentAsArray()
 {
     $html = $this->getObjArticle();
     $ret = [];
     foreach ($html->find('div.td-post-text-content/p') as $p) {
         if ($p instanceof \simple_html_dom_node) {
             if ($p->children[0]->tag != 'noindex') {
                 $string = trim($p->plaintext);
                 if (StringHelper::startsWith($string, '&nbsp;')) {
                     $string = Str::sub($string, 6);
                 }
                 $ret[] = $string;
             }
         }
     }
     return $ret;
 }
示例#10
0
 /**
  * Получает закешированные данные
  * @return array
  *   [
  *   'html' => ''
  *   'ids' => []
  *   ]
  *
  */
 public function get()
 {
     $path = $this->getPath();
     if (!file_exists($path)) {
         return '';
     }
     $data = file_get_contents($path);
     $pos = Str::pos(';', $data);
     $idsString = Str::sub($data, 0, $pos);
     if ($idsString == '') {
         $ids = [];
     } else {
         $ids = explode(',', $idsString);
     }
     $html = Str::sub($data, $pos + 1);
     return ['ids' => $ids, 'html' => $html];
 }
示例#11
0
 public function insert($fieldsCols = null)
 {
     $row = parent::insert(['beforeInsert' => function ($fields) {
         $fields['date_insert'] = time();
         $fields['id_string'] = Str::rus2translit($fields['header']);
         $fields['date'] = gmdate('Y-m-d');
         return $fields;
     }]);
     $item = new \app\models\Praktice($row);
     $fields = ['content' => Html::tag('p', Html::img(\cs\Widget\FileUpload2\FileUpload::getOriginal($item->getField('image')), ['class' => 'thumbnail', 'style' => 'width:100%;'])) . $item->getField('content')];
     if ($row['description'] == '') {
         $item = new NewsItem($row);
         $fields['description'] = GsssHtml::getMiniText($row['content']);
     }
     $item->update($fields);
     return $item;
 }
示例#12
0
 public function insert($fieldsCols = null)
 {
     $row = parent::insert(['beforeInsert' => function ($fields) {
         $fields['date_insert'] = gmdate('YmdHis');
         $fields['id_string'] = Str::rus2translit($fields['header']);
         $fields['date'] = gmdate('Y-m-d');
         return $fields;
     }]);
     $item = new \app\models\Article($row);
     $fields = [];
     if ($this->is_add_image) {
         $fields = ['content' => Html::tag('p', Html::img(\cs\Widget\FileUpload2\FileUpload::getOriginal($item->getImage()), ['class' => 'thumbnail', 'style' => 'width:100%;', 'alt' => $item->getField('header')])) . $item->getField('content')];
     }
     if ($item->getField('description', '') == '') {
         $fields['description'] = GsssHtml::getMiniText($item->getField('content', ''));
     }
     $item->update($fields);
     return $item;
 }
示例#13
0
 /**
  * @return array
  * [[
  *     'name'
  *     'url'
  * ],...]
  */
 public function getItems()
 {
     $doc = $this->getDocument($this->url);
     $ret = [];
     foreach ($doc->find('.rt-leading-articles/.rt-article') as $div) {
         $a = $div->find('.module-title/a')[0];
         $url = 'http://www.ronnastar.com' . $a->attr['href'];
         $h4 = $div->find('.module-content/h4')[0];
         $name = $h4->plaintext;
         if (Str::sub($name, 0, 1) == '«') {
             $name = Str::sub($name, 1);
         }
         if (Str::sub($name, Str::length($name) - 1, 1) == '»') {
             $name = Str::sub($name, 0, Str::length($name) - 1);
         }
         $name = Str::sub($name, 0, 1) . Str::toLower(Str::sub($name, 1));
         $ret[] = ['name' => $name, 'url' => $url];
     }
     return $ret;
 }
示例#14
0
 /**
  * @return array
  * [[
  *     'name'
  *     'url'
  * ],...]
  */
 public function getItems()
 {
     $doc = $this->getDocument($this->url);
     $ret = [];
     $c = 1;
     foreach ($doc->find('.wall_item') as $div) {
         if ($c > 1) {
             $url = 'https://vk.com' . $div->find('.wi_date')[0]->attr['href'];
             $html = $div->find('.pi_text')[0];
             $header = explode('..............................', $html->plaintext);
             $header = trim($header[0]);
             if (StringHelper::endsWith($header, '.')) {
                 $header = Str::sub($header, 0, Str::length($header) - 1);
             }
             $header = Str::toLower($header);
             $first = Str::toUpper(Str::sub($header, 0, 1));
             $header = $first . Str::sub($header, 1);
             $ret[] = ['name' => $header, 'url' => $url];
         }
         $c++;
     }
     return $ret;
 }
示例#15
0
 /**
  * Выбирает все картинки копирует в папку назначения заменяет в $content и возвращает
  *
  * @param \simple_html_dom | string $content              контент
  * @param SitePath | string         $destination          путь к папке назначения, она должна существовать
  * @param bool                      $isCopyFromRemoteHost копировать с внешних источников картинки?
  *
  * @return string
  */
 public static function copyImages2($content, $destination, $isCopyFromRemoteHost = false)
 {
     if ($content == '') {
         return '';
     }
     // выбираю все изображения из контента
     $start = 0;
     $ret = [];
     do {
         $pos = Str::pos('src="/upload/HtmlContent/', $content, $start);
         if ($pos === false) {
             break;
         }
         $end = Str::pos('"', $content, $pos + 5);
         $src = Str::sub($content, $pos + 5, $end - $pos - 5);
         $ret[] = $src;
         $start = $end;
     } while (true);
     foreach ($ret as $src) {
         $imagePath = new SitePath($src);
         // картинка не содержит путь назначения?
         if (!Str::isContain($src, $destination->getPath())) {
             try {
                 $destinationFile = $destination->cloneObject()->add($imagePath->getFileName());
                 self::resizeImage($imagePath->getPathFull(), $destinationFile->getPathFull());
                 $content = Str::replace('src="' . $src . '"', 'src="' . $destinationFile->getPath() . '"', $content);
             } catch (\Exception $e) {
                 Yii::warning($e->getMessage(), 'gs\\HtmlContent\\copyImages');
             }
         }
     }
     return $content;
 }
示例#16
0
foreach ($lastList as $item) {
    ?>
            <div class="thumbnail">
                <a href="<?php 
    echo \app\services\GsssHtml::getPrakticeUrl($item);
    ?>
"><img
                        src="<?php 
    echo $item['image'];
    ?>
"
                        style="width: 100%; display: block;"
                        > </a>
                <div class="caption">
                    <h3>
                        <?php 
    echo $item['header'];
    ?>
                    </h3>
                    <p>
                        <?php 
    echo trim(Str::sub($item['description'], 0, 200));
    ?>
                    </p>
                </div>
            </div>
        <?php 
}
?>
    </div>
</div>
示例#17
0
                            <img src="<?php 
        echo $item['image'];
        ?>
" class="thumbnail" width="80">
                        <?php 
    }
    ?>
                    </div>

                    <div class="col-lg-9">
                        <?php 
    echo Html::tag('span', GsssHtml::dateString($item['date_insert']), ['style' => 'font-size: 80%; margin-bottom:10px; color: #c0c0c0;']);
    ?>
                        <br>
                        <?php 
    echo \cs\services\Str::sub(strip_tags($item['content']), 0, 200) . '...';
    ?>
                        <br>
                        <br>
                        <button class="btn btn-danger btn-xs buttonDelete" data-id="<?php 
    echo $item['id'];
    ?>
">Удалить</button>
                        <?php 
    if (\yii\helpers\ArrayHelper::getValue($item, 'is_added_site_update', 0) == 0) {
        ?>
                            <button class="btn btn-success btn-xs buttonAddSiteUpdate" data-id="<?php 
        echo $item['id'];
        ?>
">Сделать рассылку</button>
                        <?php 
示例#18
0
 /**
  * Возвращает название статьи
  *
  * @return string
  */
 public function getHeader()
 {
     $html = $this->getObjArticle();
     $header = explode('..............................', $html->plaintext);
     $header = trim($header[0]);
     if (StringHelper::endsWith($header, '.')) {
         $header = Str::sub($header, 0, Str::length($header) - 1);
     }
     $header = Str::toLower($header);
     $first = Str::toUpper(Str::sub($header, 0, 1));
     $header = $first . Str::sub($header, 1);
     return $header;
 }
示例#19
0
                    <div class="col-lg-3">
                        <?php 
    if ($item['image'] . '' != '') {
        ?>
                            <img src="<?php 
        echo $item['image'];
        ?>
" class="thumbnail" width="80">
                        <?php 
    }
    ?>
                    </div>

                    <div class="col-lg-9">
                        <?php 
    echo \cs\services\Str::sub(strip_tags($item['description']), 0, 200) . '...';
    ?>
                        <br> <br>
                        <button class="btn btn-danger btn-xs buttonDelete" data-id="<?php 
    echo $item['id'];
    ?>
">Удалить</button>
                        <?php 
    if (\yii\helpers\ArrayHelper::getValue($item, 'is_added_site_update', 0) == 0) {
        ?>
                            <button class="btn btn-success btn-xs buttonAddSiteUpdate" data-id="<?php 
        echo $item['id'];
        ?>
">Сделать рассылку</button>
                        <?php 
    }
示例#20
0
                    </div>
                </div>
            <?php 
}
?>
        </div>
    </div>
</footer>

<div id="infoModal" class="zoom-anim-dialog mfp-hide mfp-dialog">
    <h1>Dialog example</h1>
    <p>This is dummy copy. It is not meant to be read. It has been placed here solely to demonstrate the look and feel of finished, typeset text. Only for show. He who searches for meaning here will be sorely disappointed.</p>
</div>

<?php 
if (YII_ENV == 'prod' && !\cs\services\Str::isContain(Yii::$app->controller->id, 'admin')) {
    ?>
<!-- Yandex.Metrika counter -->
<script type="text/javascript">
    (function (d, w, c) {
        (w[c] = w[c] || []).push(function() {
            try {
                w.yaCounter30774383 = new Ya.Metrika({id:30774383,
                    webvisor:true,
                    clickmap:true,
                    trackLinks:true,
                    accurateTrackBounce:true});
            } catch(e) { }
        });

        var n = d.getElementsByTagName("script")[0],
示例#21
0
</p>
            <?php 
    }
    ?>
        <?php 
}
?>

        <hr>

        <?php 
echo \app\services\Page::linkToSite($item->getField('link'));
?>

        <?php 
echo $this->render('../blocks/share', ['image' => \cs\Widget\FileUpload2\FileUpload::getOriginal(\yii\helpers\Url::to($item->getField('img'), true), false), 'url' => \yii\helpers\Url::current([], true), 'title' => $item->getField('name'), 'description' => trim(\cs\services\Str::sub(strip_tags($item->getField('description')), 0, 200))]);
//\cs\services\VarDumper::dump($category);
?>
        <?php 
if ($item->hasShop() && \yii\helpers\ArrayHelper::getValue(Yii::$app->params, 'isShop', 0) == 1) {
    ?>
            <a
                class="btn btn-primary"
                href="<?php 
    echo \yii\helpers\Url::to(['union_shop/index', 'id' => $item->getId(), 'category' => $category->getField('id_string')]);
    ?>
">Магазин</a>
        <?php 
}
?>
    </div>
示例#22
0
        <h1 class="page-header"><?php 
echo $this->title;
?>
</h1>
    </div>

    <div class="col-lg-12">
        <div class="col-lg-4 col-lg-offset-4">
            <p class="text-center">
                <img class="thumbnail" src="<?php 
echo $item->getField('image');
?>
" width="100%" alt="">
            </p>
        </div>
    </div>
    <div class="col-lg-12">
        <div class="col-lg-10 col-lg-offset-1">
            <?php 
echo $item->getField('content');
?>
            <hr>
            <?php 
echo $this->render('../blocks/share', ['image' => $item->getField('image') != '' ? Url::to(\cs\Widget\FileUpload2\FileUpload::getOriginal($item->getField('image')), true) : '', 'url' => Url::current([], true), 'title' => $item->getField('name'), 'description' => trim(\cs\services\Str::sub(strip_tags($item->getField('content')), 0, 200))]);
?>
        </div>

    </div>

</div>
示例#23
0
            <?php 
    if ($item['source'] != '') {
        ?>
                <?php 
        echo Html::a('Ссылка на источник »', $item['source'], ['class' => 'btn btn-primary', 'target' => '_blank']);
        ?>
            <?php 
    }
    ?>
        <?php 
}
$image = $item['image'];
?>

        <?php 
echo $this->render('../blocks/share', ['image' => \cs\Widget\FileUpload2\FileUpload::getOriginal(Url::to($item['image'], true), false), 'url' => Url::current([], true), 'title' => $item['header'], 'description' => trim(Str::sub(strip_tags($item['content']), 0, 200))]);
?>
        <?php 
//= \app\modules\Comment\Service::render(\app\modules\Comment\Model::TYPE_ARTICLE, $item['id']);
?>


    </div>
    <div class="col-lg-4">
        <?php 
if (\yii\helpers\ArrayHelper::getValue(Yii::$app->params, 'isMarketing', 0) == 1 && date('Y-m-d') < '2015-10-30') {
    ?>
            <?php 
    echo $this->render('../blocks/reklama');
    ?>
        <?php 
示例#24
0
 /**
  * Создает краткое содержимое текста, которое может быть также и HTML
  *
  * @param string $text
  * @param int $len
  *
  * @return string plain text
  */
 public static function getMiniText($text, $len = 200)
 {
     $htmlSpecial = ['&nbsp;' => ' ', '&#8212;' => '—'];
     $strip = strip_tags($text);
     foreach ($htmlSpecial as $code => $replaceChar) {
         $strip = str_replace($code, $replaceChar, $strip);
     }
     $strip = trim($strip);
     if (Str::length($strip) > $len) {
         return Str::sub($strip, 0, $len) . ' ...';
     }
     return $strip;
 }
示例#25
0
 /**
  * Выбирает все картинки копирует в папку назначения заменяет в $content и возвращает
  *
  * @param \simple_html_dom | string $content     контент
  * @param SitePath | string         $destination путь к папке назначения, она должна существовать
  *
  * @return string
  */
 public static function copyImages($content, $destination)
 {
     if ($content == '') {
         return '';
     }
     if (!$content instanceof \simple_html_dom) {
         require_once Yii::getAlias('@csRoot/services/simplehtmldom_1_5/simple_html_dom.php');
         $content = str_get_html($content);
     }
     foreach ($content->find('img') as $element) {
         $imagePath = new SitePath($element->attr['src']);
         // картинка не содержит путь назначения?
         if (!Str::isContain($element->attr['src'], $destination->getPath())) {
             $urlInfo = parse_url($element->attr['src']);
             if (ArrayHelper::getValue($urlInfo, 'scheme', '') == '') {
                 try {
                     $destinationFile = $destination->cloneObject()->add($imagePath->getFileName());
                     self::resizeImage($imagePath->getPathFull(), $destinationFile->getPathFull());
                     $element->attr['src'] = $destinationFile->getPath();
                 } catch (\Exception $e) {
                     Yii::warning($e->getMessage(), 'gs\\HtmlContent\\copyImages');
                 }
             } else {
                 // картинка на внешнем сервере, пока ничего не делаем
             }
         }
     }
     return $content->root->outertext();
 }
示例#26
0
 /**
  * Получает info дизайна
  *
  * @param $html
  *
  * @return array
  * [
  *    'image' => string
  *    'type' =>
  *        [
  *             'text'
  *             'href'
  *        ]
  *    'profile' =>
  *        [
  *             'text'
  *             'href'
  *        ]
  *    'definition' =>
  *        [
  *             'text'
  *        ]
  *    'inner' =>
  *        [
  *             'text'
  *        ]
  *    'strategy' =>
  *        [
  *             'text'
  *        ]
  *    'theme' =>
  *        [
  *             'text'
  *        ]
  *    'cross' =>
  *        [
  *             'text'
  *        ]
  * ]
  */
 private function getImageUrlFromHtml2($html)
 {
     $rows = explode('uk-width-1-1', $html);
     $items = explode('uk-text-primary', $rows[1]);
     $str = $items[1];
     $end = Str::pos('<', $str);
     $href = strrpos($items[0], '/');
     $href = substr($items[0], $href);
     $href = explode('>', $href);
     $Type = ['text' => Str::sub($str, 1, $end - 1), 'href' => '/types' . $href[0]];
     $items = explode('yourhumandesign.ru/profiles/profile-', $rows[2]);
     $str = $items[1];
     $Profile = ['text' => Str::sub($str, 5, 5), 'href' => '/profiles/profile-' . str_replace(' / ', '-', Str::sub($str, 5, 5))];
     $items = explode('uk-text-primary', $rows[3]);
     $str = $items[1];
     $end = Str::pos('<', $str);
     $Definition = ['text' => Str::sub($str, 2, $end - 2)];
     $items = explode('uk-text-primary', $rows[4]);
     $str = $items[1];
     $end = Str::pos('<', $str);
     $Inner = ['text' => Str::sub($str, 2, $end - 2)];
     $items = explode('uk-text-primary', $rows[5]);
     $str = $items[1];
     $end = Str::pos('<', $str);
     $Strategy = ['text' => Str::sub($str, 2, $end - 2)];
     $items = explode('uk-text-primary', $rows[6]);
     $str = $items[1];
     $end = Str::pos('<', $str);
     $Theme = ['text' => Str::sub($str, 2, $end - 2)];
     $items = explode('uk-text-primary', $rows[7]);
     $str = $items[1];
     $end = Str::pos('<', $str);
     $Cross = ['text' => Str::sub($str, 2, $end - 2)];
     $items = explode('http://www.jovianarchive.com/Content/Charts/', $rows[7]);
     $str = $items[1];
     $str = explode('.png', $str);
     $img = 'http://www.jovianarchive.com/Content/Charts/' . $str[0] . '.png';
     return ['image' => $img, 'type' => $Type, 'profile' => $Profile, 'definition' => $Definition, 'inner' => $Inner, 'strategy' => $Strategy, 'theme' => $Theme, 'cross' => $Cross];
 }
示例#27
0
 /**
  * Проверка на входной параметр и превращение из массива в строку если надо
  *
  * @param $folder
  *
  * @return string
  * @throws \Exception
  */
 private static function convert($folder)
 {
     if (is_array($folder)) {
         $folder = self::convertArrayToName($folder);
     } else {
         if (Str::isContain($folder, '..')) {
             throw new \Exception('Нельзя в параметре передавать \'..\'');
         }
     }
     return $folder;
 }
示例#28
0
 /**
  * Добавить послание из GetArticle
  *
  * @param \app\services\GetArticle\ExtractorInterface $extractor
  *
  * @return static
  * @throws \yii\base\Exception
  */
 public static function insertExtractorInterface($extractor)
 {
     $row = $extractor->extract();
     if (is_null($row['header'])) {
         throw new Exception('Нет заголовка');
     }
     if ($row['header'] == '') {
         throw new Exception('Нет заголовка');
     }
     if (is_null($row['description'])) {
         throw new Exception('Нет описания');
     }
     if ($row['description'] == '') {
         throw new Exception('Нет описания');
     }
     $fields = ['header' => $row['header'], 'content' => $row['content'], 'description' => $row['description'], 'source' => $extractor->getUrl(), 'id_string' => Str::rus2translit($row['header']), 'date_insert' => gmdate('YmdHis'), 'date' => gmdate('Ymd'), 'img' => ''];
     $articleObject = self::insert($fields);
     $model = new \app\models\Form\Chenneling();
     $model->id = $articleObject->getId();
     $image = $row['image'];
     if ($image) {
         try {
             $imageContent = file_get_contents($image);
             $imageUrl = parse_url($image);
             $pathInfo = pathinfo($imageUrl['path']);
             $pathInfo['extension'];
             $fields = FileUpload::save(File::content($imageContent), $pathInfo['extension'], ['img', 'Картинка', 0, 'string', 'widget' => [FileUpload::className(), ['options' => ['small' => \app\services\GsssHtml::$formatIcon]]]], $model);
             $articleObject->update($fields);
         } catch (\Exception $e) {
         }
     }
     return $articleObject;
 }
示例#29
0
 /**
  * @param string|int|DateTime $date UTC
  *
  * @return \cs\models\Response
  * integer - unix time
  */
 private static function convertDate($date)
 {
     if (is_string($date)) {
         if (Str::isContain($date, '-')) {
             return Response::success((new \DateTime($date, new \DateTimeZone('UTC')))->format('U'));
         } else {
             return Response::success((int) $date);
         }
     } else {
         if (is_integer($date)) {
             return Response::success($date);
         } else {
             if ($date instanceof DateTime) {
                 return Response::success($date->format('U'));
             } else {
                 return Response::error('Не верный формат данных');
             }
         }
     }
 }