Beispiel #1
0
use frontend\models\ArticleContent;
use pavlinter\display\DisplayImage;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Inflector;
use yii\helpers\StringHelper;
if ($items) {
    echo '<div class="perexes-list">';
    if ($columnsCount > 3) {
        $columnsCount = 3;
    }
    $i = 0;
    foreach ($items as $item) {
        $articleUrlParts = ['page/article', 'ida' => $item->id, 'article' => Inflector::slug(strip_tags($item->title)), 'web' => \Yii::$app->request->get('web'), 'language' => \Yii::$app->request->get('language')];
        if (!$menuUrlParts) {
            $menuUrlParts = ArticleContent::getMenuUrlParts($item->id);
        }
        $url = ArrayHelper::merge($articleUrlParts, $menuUrlParts);
        $test = $i % $columnsCount;
        if ($test == 0) {
            echo '<div class="row">';
        }
        echo '<div class="col s12' . ($columnsCount == 2 ? ' l6' : ($columnsCount == 3 ? ' l4' : '')) . '">';
        echo '<div class="row">';
        if ($withImage) {
            echo '<div class="col s12 l1">';
            if (isset($item->image)) {
                $image = DisplayImage::widget(['width' => $maxImageSize['width'], 'height' => $maxImageSize['height'], 'options' => ['class' => 'responsive-img hoverable', 'title' => $item->title], 'category' => 'all', 'image' => $item->image->filename]);
                echo Html::a($image, $url);
            }
            echo '</div>';
Beispiel #2
0
 /**
  * Sets found items array
  * @param $data
  * @param $type
  */
 private function setItems($data, $type)
 {
     foreach ($data as $item) {
         $this->items[] = ['id' => $type != 'article' ? $item->id : $item['article_id'], 'title' => $type != 'article' ? $item->title : $item['article_title'], 'breadcrumbs' => MenuContent::getBreadCrumbs($type != 'article' ? $item->parent_id : $item['menu_item_id'], [], false), 'perex' => StringHelper::truncateWords($type == 'category' ? $item->category->description : ($type == 'content' ? $item->content->perex ? $item->content->perex : $item->content->description : $item['perex']), 30), 'url' => $type != 'article' ? $item->getUrl() : ArticleContent::getUrl($item['menu_item_title'], $item['menu_item_id'], $item['article_title'], $item['article_id']), 'updated_at' => $type != 'article' ? $item->updated_at : $item['article_updated_at']];
     }
 }
Beispiel #3
0
 /**
  * Action for generating article
  * @param $ida
  * @param null $type
  * @return string
  */
 public function actionArticle($ida, $type = null)
 {
     Url::remember('', 'page');
     /** @var ArticleContent $articleContent */
     $articleContent = ArticleContent::findOne($ida);
     if ($articleContent->layout) {
         $viewName = $articleContent->layout->filename;
     } else {
         $viewName = 'article';
     }
     if ($type == 'pdf') {
         /** @noinspection PhpUndefinedFieldInspection */
         $pdf = Yii::$app->pdf;
         $pdf->content = $this->renderPartial('pdf/' . $viewName, ['content' => $articleContent]);
         $pdf->options['title'] = $articleContent->title;
         $pdf->methods['SetFooter'] = ['{PAGENO}'];
         return $pdf->render();
     } else {
         return $this->render($viewName, ['menuContent' => $this->_menuContent, 'articleContent' => $articleContent]);
     }
 }
            $invitationsMenuUrlParts = ArticleContent::getMenuUrlParts($item->id);
        }
        $url = ArrayHelper::merge($articleUrlParts, $invitationsMenuUrlParts);
        echo $this->renderFile('@frontend/components/homepage/views/_invitationActuality.php', ['item' => $item, 'url' => $url, 'maxImageSize' => $maxImageSize, 'wordsCount' => $wordsCount, 'columnsCount' => $columnsCount, 'itemType' => 'invitation']);
        if ($test == $columnsCount - 1) {
            echo '</div>';
        }
        ++$i;
    }
    foreach ($actualitiesItems as $item) {
        $test = $i % $columnsCount;
        if ($test == 0) {
            echo '<div class="row">';
        }
        $articleUrlParts = ['page/article', 'ida' => $item->id, 'article' => Inflector::slug(strip_tags($item->title)), 'web' => \Yii::$app->request->get('web'), 'language' => \Yii::$app->request->get('language')];
        if (!$actualitiesMenuUrlParts) {
            $actualitiesMenuUrlParts = ArticleContent::getMenuUrlParts($item->id);
        }
        $url = ArrayHelper::merge($articleUrlParts, $actualitiesMenuUrlParts);
        echo $this->renderFile('@frontend/components/homepage/views/_invitationActuality.php', ['item' => $item, 'url' => $url, 'maxImageSize' => $maxImageSize, 'wordsCount' => $wordsCount, 'columnsCount' => $columnsCount, 'itemType' => 'actuality']);
        if ($test == $columnsCount - 1) {
            echo '</div>';
        }
        ++$i;
    }
    if ($test != $columnsCount - 1) {
        echo '</div>';
    }
    echo '</div>';
    echo '</div>';
}