Esempio n. 1
0
 public function display($content = null)
 {
     if ($content != null) {
         $this->content = $content;
     }
     echo Html::encode($this->content);
 }
 /**
  * ЦСКА
  */
 public function actionCskanews()
 {
     $cska = Yii::$app->params['cska'];
     $bot = new BotApi($cska['token']);
     $host = 'https://www.sports.ru';
     $dom = Html::load($cska['html']);
     $divs = $dom->getElementsByTagName('div');
     foreach ($divs as $div) {
         if ($div->getAttribute('class') == 'news') {
             $links = $div->getElementsByTagName('a');
             foreach ($links as $link) {
                 if ($link->getAttribute('class') == 'short-text') {
                     $url = Url::findOne(['channel' => 'cska', 'url' => $host . $link->getAttribute('href')]);
                     if ($url === null) {
                         $message = $link->nodeValue . "\n" . $host . $link->getAttribute('href');
                         try {
                             $bot->sendMessage($cska['chat_id'], $message);
                         } catch (Exception $e) {
                             echo $e->getMessage() . "\n";
                         }
                         $url = new Url(['channel' => 'cska', 'url' => $host . $link->getAttribute('href')]);
                         $url->save();
                     }
                 }
             }
         }
     }
 }
Esempio n. 3
0
 /**
  * Возвращает количество оставшихся трансферов
  */
 public function getTransfers()
 {
     $dom = Html::load($this->url);
     $tables = $dom->getElementsByTagName('table');
     foreach ($tables as $table) {
         if ($table->getAttribute('class') == 'profile-table') {
             $trs = $table->getElementsByTagName('tr');
             foreach ($trs as $tr) {
                 if ($tr->getElementsByTagName('th')->item(0)->nodeValue == 'Трансферы в туре') {
                     $transfers = $tr->getElementsByTagName('td')->item(0)->nodeValue;
                 }
             }
         }
     }
     return isset($transfers) ? $transfers : 0;
 }
 /**
  * Обновление дедлайнов турнира
  */
 public function actionDeadlines()
 {
     $tournaments = Tournament::find()->all();
     $month = ['января' => 1, 'февраля' => 2, 'марта' => 3, 'апреля' => 4, 'мая' => 5, 'июня' => 6, 'июля' => 7, 'августа' => 8, 'сентября' => 9, 'октября' => 10, 'ноября' => 11, 'декабря' => 12];
     foreach ($tournaments as $tournament) {
         $team = Team::findOne(['tournament_id' => $tournament->id]);
         if ($team !== null) {
             $dom = Html::load($team->url);
             $tables = $dom->getElementsByTagName('table');
             foreach ($tables as $table) {
                 if ($table->getAttribute('class') == 'profile-table') {
                     $trs = $table->getElementsByTagName('tr');
                     foreach ($trs as $tr) {
                         if ($tr->getElementsByTagName('th')->item(0)->nodeValue == 'Дедлайн') {
                             $deadline = $tr->getElementsByTagName('td')->item(0)->nodeValue;
                             $deadline = str_replace(['|', ':'], ' ', $deadline);
                             $deadline = explode(' ', $deadline);
                             if (count($deadline) == 4) {
                                 $year = date('Y');
                                 $time = mktime($deadline[2], $deadline[3], 0, $month[$deadline[1]], $deadline[0], $year);
                                 $now = time();
                                 if ($time < $now) {
                                     $year++;
                                     $time = mktime($deadline[2], $deadline[3], 0, $month[$deadline[1]], $deadline[0], $year);
                                 }
                                 $deadline = date('Y-m-d H:i:s', $time);
                             }
                         } elseif ($tr->getElementsByTagName('th')->item(0)->nodeValue == 'Трансферы в туре') {
                             $transfers = $tr->getElementsByTagName('td')->item(0)->nodeValue;
                         }
                     }
                 }
             }
             if ($tournament->deadline != $deadline) {
                 $tournament->deadline = $deadline;
                 if (isset($transfers)) {
                     $tournament->checked = false;
                     $tournament->transfers = $transfers;
                 } else {
                     $tournament->checked = true;
                 }
                 $tournament->save();
             }
         }
     }
 }
Esempio n. 5
0
 /**
  * Обновляет список команд пользователя
  */
 public function updateTeams()
 {
     if (!empty($this->profile_url)) {
         // Запоминаем старые команды
         $oldTeams = [];
         foreach ($this->teams as $team) {
             $oldTeams[] = $team->url;
         }
         // Получаем список новых команд
         $dom = Html::load($this->profile_url . 'fantasy/');
         $divs = $dom->getElementsByTagName('div');
         $host = 'https://www.sports.ru';
         foreach ($divs as $div) {
             if ($div->getAttribute('class') == 'item user-league') {
                 $links = $div->getElementsByTagName('a');
                 $tournamentUrl = $host . $links->item(1)->getAttribute('href');
                 if (preg_match('/.*\\/fantasy\\/football\\/.*/', $tournamentUrl)) {
                     // Проверяем турнир к которому относится команда
                     $tournament = Tournament::findOne(['url' => $tournamentUrl]);
                     if ($tournament === null) {
                         $tournament = new Tournament(['url' => $tournamentUrl, 'name' => $links->item(1)->nodeValue]);
                         $tournament->save();
                     }
                     // Добавляем команду
                     $teamUrl = $host . $links->item(0)->getAttribute('href');
                     $teamUrl = str_replace('/football/team/', '/football/team/points/', $teamUrl);
                     $team = Team::findOne(['url' => $teamUrl]);
                     if ($team === null) {
                         $team = new Team(['user_id' => $this->id, 'url' => $teamUrl, 'name' => $links->item(0)->nodeValue, 'tournament_id' => $tournament->id]);
                         $team->save();
                     } else {
                         $index = array_search($teamUrl, $oldTeams);
                         array_splice($oldTeams, $index, 1);
                     }
                 }
             }
         }
         // Удаляем старые команды
         foreach ($oldTeams as $url) {
             $team = Team::findOne(['url' => $url]);
             if ($team !== null) {
                 $team->delete();
             }
         }
     }
 }
Esempio n. 6
0
 public function run()
 {
     if ($this->box) {
         if ($this->responsive) {
             $this->box['body']['class'] = 'table-responsive';
         }
         self::boxBegin($this->box);
     } elseif ($this->responsive) {
         Html::beginTag('div', ['class' => 'table-responsive']);
     }
     parent::run();
     if ($this->box) {
         self::boxEnd();
     } elseif ($this->responsive) {
         Html::endTag('div');
     }
 }
Esempio n. 7
0
 public function run()
 {
     echo Html::beginTag('div', ['class' => 'info-box ' . ($this->bgFill ? $this->bg : '')]);
     if (!$this->icon) {
         $this->icon = Html::fa('question', 'i');
     }
     echo Html::tag('span', $this->icon, ['class' => 'info-box-icon ' . ($this->bgFill ? '' : $this->bg)]);
     echo Html::beginTag('div', ['class' => 'info-box-content']);
     echo Html::tag('span', $this->text, ['class' => 'info-box-text']);
     echo Html::tag('span', $this->number, ['class' => 'info-box-number']);
     if ($this->progress !== null) {
         echo Html::tag('div', Html::tag('div', '', ['class' => 'progress-bar', 'style' => 'width: ' . $this->progress . '%;']), ['class' => 'progress']);
         if (!empty($this->progressText)) {
             echo Html::tag('div', $this->progressText, ['class' => 'progress-description']);
         }
     }
     echo Html::endTag('div');
     echo Html::endTag('div');
 }
Esempio n. 8
0
 /**
  * Check to see if a child item is active optionally activating the parent.
  * @param array $items @see items
  * @param boolean $active should the parent be active too
  * @return array @see items
  */
 protected function isChildActive($items, &$active)
 {
     foreach ($items as $i => $child) {
         if (ArrayHelper::remove($items[$i], 'active', false) || $this->isItemActive($child)) {
             Html::addCssClass($items[$i]['options'], 'active');
             if ($this->activateParents) {
                 $active = true;
             }
         }
     }
     return $items;
 }
 public function init()
 {
     $this->homeLink = ['label' => Html::fa('dashboard') . ' Home', 'url' => ['site/index'], 'encode' => false];
     parent::init();
 }
Esempio n. 10
0
<?php

/* @var $this app\components\View */
use app\components\Html;
use app\widgets\Table;
use yii\bootstrap\Progress;
use yii\widgets\Pjax;
$this->title = 'Simple Tables';
$this->subTitle = 'preview of simple tables';
$labels = ['#', 'Task', 'Progress', 'Label'];
$data = [['Update software', 55, 'danger', 'red'], ['Clean database', 70, 'warning', 'yellow'], ['Cron job running', 30, 'info', 'blue'], ['Fix and squish bugs', 90, 'success', 'green']];
$models = [];
$cnt = 0;
foreach ($data as $datum) {
    $models[] = ['#' => ++$cnt . '.', 'task' => $datum[0], 'progress' => Progress::widget(['percent' => $datum[1], 'options' => ['class' => 'progress-xs'], 'barOptions' => ['class' => 'progress-bar-' . $datum[2]]]), 'label' => Html::badge($datum[1] . '%', 'bg-' . $datum[3])];
}
$columns = ['#', 'task', 'progress:html', 'label:html'];
?>


<div class="row">
    <div class="col-xs-6">
        <?php 
echo Table::widget(['box' => ['type' => 'primary', 'header' => ['title' => 'Bordered Table']], 'data' => $models, 'columns' => $columns]);
?>
        <?php 
echo Table::widget(['box' => ['type' => 'primary', 'header' => ['title' => 'Condensed Full Width Table'], 'noPadding' => true], 'type' => 'table-condensed', 'data' => $models, 'columns' => $columns]);
?>
    </div><!-- /.col -->
    <div class="col-xs-6">
        <?php 
Esempio n. 11
0
            </div>
        </div>

    </div>
    <div class="col-md-4">
        <?php 
echo InfoBox::widget(['bg' => 'bg-yellow', 'bgFill' => true, 'icon' => Html::ion('ios-pricetag-outline'), 'text' => 'INVENTORY', 'number' => '5,200', 'progress' => '50', 'progressText' => '50% Increase in 30 Days']);
?>
        <?php 
echo InfoBox::widget(['bg' => 'bg-green', 'bgFill' => true, 'icon' => Html::ion('ios-heart-outline'), 'text' => 'MENTIONS', 'number' => '92,050', 'progress' => '20', 'progressText' => '20% Increase in 30 Days']);
?>
        <?php 
echo InfoBox::widget(['bg' => 'bg-red', 'bgFill' => true, 'icon' => Html::ion('ios-cloud-download-outline'), 'text' => 'DOWNLOADS', 'number' => '114,381', 'progress' => '70', 'progressText' => '70% Increase in 30 Days']);
?>
        <?php 
echo InfoBox::widget(['bg' => 'bg-aqua', 'bgFill' => true, 'icon' => Html::ion('ios-chatbubble-outline'), 'text' => 'DIRECT MESSAGES', 'number' => '163,921', 'progress' => '40', 'progressText' => '40% Increase in 30 Days']);
?>

        <?php 
echo Box::begin(['type' => '', 'header' => ['title' => 'Browser Usage']]);
?>
        <?php 
echo Box::end();
?>

    </div>
</div>

<div class="row">
    <div class="col-md-8">
        <?php 
Esempio n. 12
0
<div class="row">
    <div class="col-md-6">
        <?php 
echo Collapse::widget([]);
?>
    </div>

    <div class="col-md-6">



        <?php 
echo Box::begin(['type' => 'success', 'noPadding' => true, 'header' => ['title' => 'Carousel']]);
?>

        <?php 
echo Carousel::widget(['items' => ['<img src="http://placehold.it/900x500/f39c12/ffffff&text=I+Love+Bootstrap"/>', ['content' => '<img src="http://placehold.it/900x500/ff0000/ffffff&text=I+Love+Bootstrap"/>'], ['content' => '<img src="http://placehold.it/900x500/ffcc00/ffffff&text=I+Love+Bootstrap"/>', 'caption' => '<h4>This is title</h4><p>This is the caption text</p>', 'options' => []]], 'controls' => ['<span class="fa fa-angle-left"></span>', '<span class="fa fa-angle-right"></span>']]);
?>
        <?php 
echo Box::end();
?>
    </div>


</div>


<?php 
echo Html::pageHeader('Typography');
Esempio n. 13
0
 public function timeAgo(DateTime $d)
 {
     return Html::el('time')->setText($d->format('j.n.Y H:i'))->addAttributes(['datetime' => $d->format('c')]);
 }