コード例 #1
0
ファイル: GsssHtml.php プロジェクト: dram1008/gleb
 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']);
 }
コード例 #2
0
ファイル: PageController.php プロジェクト: Makeyko/galaxysss
 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')])]);
 }
コード例 #3
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]);
 }