Ejemplo n.º 1
0
 public static function unityCategoryItem($row)
 {
     if (!is_array($row)) {
         $id = $row;
         $item = UnionCategory::find($id);
         if (is_null($item)) {
             return '';
         }
         $row = $item->getFields();
     }
     // Заголовок
     $html[] = Html::tag('div', Html::tag('h2', $row['header']), ['class' => 'header']);
     // подзаголовок
     if (ArrayHelper::keyExists('sub_header', $row)) {
         $html[] = Html::tag('p', $row['sub_header']);
     }
     // картинка с ссылкой
     $html[] = Html::tag('p', Html::a(Html::img($row['image'], ['width' => '100%', 'class' => 'thumbnail']), Url::to(['page/category', 'id' => $row['id_string']])));
     // Описание
     $html[] = Html::tag('p', self::getMiniText($row['description']));
     return Html::tag('div', join('', $html), ['class' => 'col-lg-4 unityCategoryItem']);
 }
Ejemplo n.º 2
0
 /**
  * Возвращает ссылку на объединение
  *
  * @param bool $isScheme
  *
  * @return string
  */
 public function getLink($isScheme = false)
 {
     $tree_node_id = $this->getField('tree_node_id');
     $idString = UnionCategory::getIdStringById($tree_node_id);
     if ($idString === false) {
         return '';
     }
     $url = Url::to(['page/union_item', 'category' => $idString, 'id' => $this->getId()]);
     return Url::to($url, $isScheme);
 }
Ejemplo n.º 3
0
 public function actionArticle($category, $year, $month, $day, $id)
 {
     $item = Article::find(['id_string' => $id, 'DATE(date_insert)' => $year . $month . $day]);
     if (is_null($item)) {
         throw new Exception('Нет такой статьи');
     }
     $categoryObject = UnionCategory::find(['id_string' => $category]);
     $item->incViewCounter();
     $nearList = Article::getByTreeNodeIdQuery($categoryObject->getId())->andWhere(['not in', 'id', $item->getId()])->limit(3)->all();
     if (count($nearList) == 0) {
         $nearList = Article::query()->select('id,header,id_string,image,view_counter,description,content,date_insert')->orderBy(['date_insert' => SORT_DESC])->andWhere(['not in', 'id', $item->getId()])->limit(3)->all();
     }
     return $this->render(['item' => $item->getFields(), 'category' => $category, 'nearList' => $nearList, 'breadcrumbs' => $categoryObject->getBreadCrumbs([$item->getField('header')])]);
 }
Ejemplo n.º 4
0
 /**
  * Продукт
  *
  * @param $category string id_string
  * @param $union_id int идентификатор объединения
  * @param $id int идентификатор продукта gs_unions_shop_product.id
  *
  * @return string
  * @throws \cs\web\Exception
  */
 public function actionProduct($category, $union_id, $id)
 {
     $item = Union::find($union_id);
     if (is_null($item)) {
         throw new Exception('Нет такого объединения');
     }
     $categoryObject = UnionCategory::find(['id_string' => $category]);
     if (is_null($categoryObject)) {
         throw new Exception('Не найдена категория');
     }
     $product = Product::find($id);
     if (is_null($product)) {
         throw new Exception('Не найден товар');
     }
     $treeNode = TreeNode::find($product->getField('tree_node_id'));
     $breadcrumbs = $categoryObject->getBreadCrumbs();
     $breadcrumbs = ArrayHelper::merge($breadcrumbs, [['url' => ['page/union_item', 'id' => $item->getId(), 'category' => $categoryObject->getField('id_string')], 'label' => $item->getName()], ['url' => ['union_shop/index', 'id' => $item->getId(), 'category' => $categoryObject->getField('id_string')], 'label' => 'Магазин'], ['url' => ['union_shop/category', 'id' => $item->getId(), 'category' => $categoryObject->getField('id_string'), 'shop_category' => $product->getField('tree_node_id')], 'label' => $treeNode->getField('name')], $product->getField('name')]);
     return $this->render(['union' => $item, 'shop' => $item->getShop(), 'breadcrumbs' => $breadcrumbs, 'category' => $categoryObject, 'treeNode' => $treeNode, 'product' => $product]);
 }
Ejemplo n.º 5
0
/** @var array  $articleList */
use yii\helpers\Url;
$this->title = 'Время';
?>
<div class="container">

    <div class="page-header">
        <h1>Время</h1>
    </div>
    <p class="lead">Когда время согласовано с ритмами природы, тогда мы можем мыслить в масштабах Вечности.</p>

    <p><img src="/images/page/time/2.jpg" width="100%" class="thumbnail"></p>

    <div class="row">
        <?php 
foreach (\app\models\UnionCategory::getRows(2) as $item) {
    echo \app\services\GsssHtml::unityCategoryItem($item);
}
?>
        <?php 
echo \app\services\GsssHtml::unionCategoryItems(2);
?>
    </div>
    <?php 
if (count($articleList) > 0) {
    ?>
        <div class="row">
            <div class="page-header">
                <h2>Статьи</h2>
            </div>
            <div class="row">
Ejemplo n.º 6
0
 /**
  * Возвращает ссылку на статью
  *
  * @param bool $isScheme надо ли добавлять полный путь
  *
  * @return string
  */
 public function getLink($isScheme = false)
 {
     $date = $this->getField('date');
     $year = substr($date, 0, 4);
     $month = substr($date, 5, 2);
     $day = substr($date, 8, 2);
     return \yii\helpers\Url::to(['page/article', 'year' => $year, 'month' => $month, 'day' => $day, 'id' => $this->getField('id_string'), 'category' => UnionCategory::getIdStringById((new BitMask($this->getField('tree_node_id_mask')))->getArray()[0])], $isScheme);
 }