- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
$breadcrumb = array();
$breadcrumb[0] = new Json();
$breadcrumb[0]->url = URL::base().'cat';
$breadcrumb[0]->caption = 'Каталог';
try {
if(isset($_GET['q'])) {
$qs = $_GET['q'];
$matches = array();
$count = preg_match_all("/\d+/", $qs, $matches);
if ($count > 1) {
$lc = $matches[0][0];
$vc = $matches[0][1];
list ($totalCount, $thumbnails, $lamps_orm, $formCount) = Imp::getVariants($lc, $vc, $p);
list ($form, $formList) = Imp::getForms($lamps_orm[0]->f->latin);
$this->template->title = $lamps_orm[0]->cyrillic;
$lampName = $lamps_orm[0]->cyrillic;
$breadcrumb[1] = new Json();
$breadcrumb[1]->url = URL::base().'cat/'.$form->c->latin;
$breadcrumb[1]->caption = $form->c->cyrillic;
$breadcrumb[2] = new Json();
$breadcrumb[2]->url = URL::base().'lamp/'.$form->latin;
$breadcrumb[2]->caption = $form->cyrillic;
$breadcrumb[3] = new Json();
$breadcrumb[3]->url = URL::base().'lamp/search/?q='.$lamps_orm[0]->code;
$breadcrumb[3]->caption = $lamps_orm[0]->cyrillic;
$breadcrumb[4] = new Json();
$breadcrumb[4]->url = NULL;
$breadcrumb[4]->caption = $thumbnails[0]->code;
} elseif ($count == 1) {
$lc = $matches[0][0];
list ($totalCount, $thumbnails, $lamps_orm, $formCount) = Imp::getVariants($lc, NULL, $p);
list ($form, $formList) = Imp::getForms($lamps_orm[0]->f->latin);
$this->template->title = $lamps_orm[0]->cyrillic;
$lampName = $lamps_orm[0]->cyrillic;
$breadcrumb[1] = new Json();
$breadcrumb[1]->url = URL::base().'cat/'.$form->c->latin;
$breadcrumb[1]->caption = $form->c->cyrillic;
$breadcrumb[2] = new Json();
$breadcrumb[2]->url = URL::base().'lamp/'.$form->latin;
$breadcrumb[2]->caption = $form->cyrillic;
$breadcrumb[3] = new Json();
$breadcrumb[3]->url = NULL;
$breadcrumb[3]->caption = $lamps_orm[0]->cyrillic;
} else {
list ($totalCount, $thumbnails, $lamps_orm, $formCount) = Imp::getVariants($qs, NULL, $p);
list ($form, $formList) = Imp::getForms($lamps_orm[0]->f->latin);
if (count($lamps_orm) > 1) {
$this->template->title = $form->cyrillic;
$lampName = $form->cyrillic;
$breadcrumb[1] = new Json();
$breadcrumb[1]->url = URL::base().'cat/'.$form->c->latin;
$breadcrumb[1]->caption = $form->c->cyrillic;
$breadcrumb[2] = new Json();
$breadcrumb[2]->url = NULL;
$breadcrumb[2]->caption = $form->cyrillic;
if ($formCount > 1) {
$breadcrumb = array();
$breadcrumb[0] = new Json();
$breadcrumb[0]->url = NULL;
$breadcrumb[0]->caption = 'Результаты поиска';
$this->template->title = 'Результаты поиска по запросу "'.$qs.'"';
$lampName = 'Результаты поиска по запросу "'.$qs.'"';
}
} else {
$this->template->title = $lamps_orm[0]->cyrillic;
$lampName = $lamps_orm[0]->cyrillic;
$breadcrumb[1] = new Json();
$breadcrumb[1]->url = URL::base().'cat/'.$form->c->latin;
$breadcrumb[1]->caption = $form->c->cyrillic;
$breadcrumb[2] = new Json();
$breadcrumb[2]->url = URL::base().'lamp/'.$form->latin;
$breadcrumb[2]->caption = $form->cyrillic;
$breadcrumb[3] = new Json();
$breadcrumb[3]->url = NULL;
$breadcrumb[3]->caption = $lamps_orm[0]->cyrillic;
}
}
$pagination = Imp::getPagination($totalCount, 16, $p, 'lamp/search/:page/?q='.$qs);
} else {
list ($form, $formList) = Imp::getForms($f);
if (isset($_GET['y'])) {
list ($totalCount, $thumbnails, $lamps_orm, $formCount) = Imp::getVariants($form, 'form', $p, array(0, 1), $_GET['y'], $_GET['m'], $_GET['d']);
$paginationUrlFormat = 'lamp/'.$f.'/:page/?y='.$_GET['y'].'&m='.$_GET['m'].'&d='.$_GET['d'];
$lampName = $form->cyrillic.' <span style="color: #666; font-style: oblique;"><small>Показаны обновления от '.D::_($_GET['y'].'-'.$_GET['m'].'-'.$_GET['d']).'. <a href="'.URL::base().'lamp/'.$f.'" style="font-weight: normal; font-style: normal;">Показать все варианты ›</a></small></span>';
}
else {
list ($totalCount, $thumbnails, $lamps_orm, $formCount) = Imp::getVariants($form, 'form', $p);
$paginationUrlFormat = 'lamp/'.$f.'/:page';
$lampName = $form->cyrillic;
}
$this->template->title = $form->cyrillic;
$pagination = Imp::getPagination($totalCount, 16, $p, $paginationUrlFormat);
$breadcrumb[1] = new Json();
$breadcrumb[1]->url = URL::base().'cat/'.$form->c->latin;
$breadcrumb[1]->caption = $form->c->cyrillic;
$breadcrumb[2] = new Json();
$breadcrumb[2]->url = NULL;
$breadcrumb[2]->caption = $form->cyrillic;
}
Кусок контроллера трехлетней давности. В данный момент готовлю это к утилизации. А, когда я это писал, мне казалось, что я крут.
В то время на хостинге не было json_encode/json_decode, поэтому сделал класс Json. Хотя, использовал его просто так, чтобы не создавать кучу специализированных классов.
noganno 25.08.2021 08:35 # 0