From 51413b7062694db20d7282d96975b059961fa2c0 Mon Sep 17 00:00:00 2001 From: flk Date: Tue, 5 May 2015 13:29:41 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA?= =?UTF-8?q?=20=D1=83=D1=80=D0=BE=D0=B2=D0=BD=D1=8F=20NOTICE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +++- Pages/Group.php | 23 ++++++++++++++++++----- Pages/Models.php | 10 ++++++---- View/common/breadcumbs.tpl | 2 +- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index a77c96c..0775b2c 100755 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ tmp/smarty/* -vendor \ No newline at end of file +vendor +.idea +vde \ No newline at end of file diff --git a/Pages/Group.php b/Pages/Group.php index f668e5c..2dd6ae6 100755 --- a/Pages/Group.php +++ b/Pages/Group.php @@ -10,8 +10,18 @@ use NS\TecDocSite\Interfaces\PageInterface; class Group implements PageInterface { + /** + * Варианты отображения единиц на страницу. + * + * @var int[] + */ private $itemsPerPage = array(20, 40, 100); + /** + * Дефолтный вид отображения плитка + */ + const DEFAULT_VIEW_MODE = 'tile'; + /** * Возвращает html дерева категорий для модификации. * @@ -25,9 +35,10 @@ public function getHtml() { $modificationId = $_GET['modelVariant']; $categoryId = $_GET['group']; $articles = $tecDocRestClient->getArticles($modificationId, $categoryId); - $itemsPerPage = in_array($_GET['itemsPerPage'], $this->itemsPerPage, TRUE) ? $_GET['itemsPerPage'] : current($this->itemsPerPage); + $viewMode = isset($_GET['viewMode']) ? $_GET['viewMode'] : self::DEFAULT_VIEW_MODE; + $itemsPerPage = isset($_GET['itemsPerPage']) && in_array($_GET['itemsPerPage'], $this->itemsPerPage, TRUE) ? $_GET['itemsPerPage'] : current($this->itemsPerPage); $totalArticles = count($articles); - $start = is_numeric($_GET['start']) && $_GET['start'] < $totalArticles && $_GET['start'] > 0 ? $_GET['start'] : 0; + $start = isset($_GET['start']) && is_numeric($_GET['start']) && $_GET['start'] < $totalArticles && $_GET['start'] > 0 ? $_GET['start'] : 0; $articles = array_slice($articles, $start, $itemsPerPage); $baseUrlArray = array( 'man' => $_GET['man'], @@ -46,14 +57,15 @@ public function getHtml() { 'itemsPerPareValues' => $this->itemsPerPage, 'selectedItemsPerPage' => $itemsPerPage, 'baseUrl' => $baseUrl, - 'viewMode' => $_GET['viewMode'], - 'itemsPerPage' => $_GET['itemsPerPage'], - 'start' => $_GET['start'], + 'viewMode' => $viewMode, + 'itemsPerPage' => $itemsPerPage, + 'start' => $start, 'paginator' => isset($paginator) ? $paginator->deploy() : '', 'articles' => $articles ); $content = View::deploy('group.details.tpl', $contentTemplateData); $templateData = array('content' => $content); + return View::deploy('index.tpl', $templateData); } @@ -100,6 +112,7 @@ private static function getBreadcrumbs() { $templateData = array( 'breadcrumbs' => $breadcrumbs ); + return View::deploy('common/breadcumbs.tpl', $templateData); } } \ No newline at end of file diff --git a/Pages/Models.php b/Pages/Models.php index 1611723..0faea12 100755 --- a/Pages/Models.php +++ b/Pages/Models.php @@ -23,19 +23,19 @@ public function getHtml() { $begin = 1990; $end = (int)date('Y'); $step = 10; - $yearFilterValue = (int)$_GET['yearFilter']; - $selectedYear = $yearFilterValue ? $yearFilterValue : 'all'; + $selectedYear = isset($_GET['yearFilter']) && isset($_GET['yearFilter']) ? (int)$_GET['yearFilter'] : 'all'; $yearsFilter = array(); $outModels = array(); for ($i = $begin - $step; $i < $end; $i += $step) { $yearsFilter[] = array( 'begin' => $i < $begin ? 0 : $i, 'end' => $i >= $end - $step ? $end : $i + $step, - 'endView' => $i >= $end - $step ? '' : $i + $step + 'endView' => $i >= $end - $step ? '' : $i + $step, + 'isVisible' => FALSE ); } + $isModelVisible = $selectedYear === 'all'; foreach ($dataModels as $oneModel) { - $isModelVisible = $selectedYear === 'all'; $yearTo = $oneModel->yearTo ? $oneModel->yearTo : new \DateTime(); $yearFrom = $oneModel->yearFrom ? $oneModel->yearFrom : new \DateTime('1970-01-01'); foreach ($yearsFilter as &$oneRangeValue) { @@ -61,6 +61,7 @@ public function getHtml() { $templateData = array( 'content' => View::deploy('models.tpl', $contentTemplateData) ); + return View::deploy('index.tpl', $templateData); } @@ -89,6 +90,7 @@ private static function getBreadcrumbs() { $templateData = array( 'breadcrumbs' => $breadcrumbs ); + return View::deploy('common/breadcumbs.tpl', $templateData); } } \ No newline at end of file diff --git a/View/common/breadcumbs.tpl b/View/common/breadcumbs.tpl index 3f6ca28..1d2ebb4 100644 --- a/View/common/breadcumbs.tpl +++ b/View/common/breadcumbs.tpl @@ -1,7 +1,7 @@ Каталог {foreach from=$data.breadcrumbs item=oneItem} - {if $oneItem.url} + {if isset($oneItem.url)} {$oneItem.name} {else} {$oneItem.name}