Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/reviews/reviews_event_handler.php
Show First 20 Lines • Show All 579 Lines • ▼ Show 20 Line(s) | |||||
if (preg_match('/(.*)-rev/', $event->Prefix, $regs) && $this->Application->prefixRegistred($regs[1])) { | if (preg_match('/(.*)-rev/', $event->Prefix, $regs) && $this->Application->prefixRegistred($regs[1])) { | ||||
// "Structure & Data" -> "Reviews" (section in K4) | // "Structure & Data" -> "Reviews" (section in K4) | ||||
// 1. add join to items table (for "Structure & Data" -> "Reviews" section) | // 1. add join to items table (for "Structure & Data" -> "Reviews" section) | ||||
$item_table = $this->Application->getUnitOption($regs[1], 'TableName'); | $item_table = $this->Application->getUnitOption($regs[1], 'TableName'); | ||||
$ci_table = $this->Application->getUnitOption('ci', 'TableName'); | $ci_table = $this->Application->getUnitOption('ci', 'TableName'); | ||||
/** @var array $list_sqls */ | |||||
$list_sqls = $this->Application->getUnitOption($event->Prefix, 'ListSQLs'); | $list_sqls = $this->Application->getUnitOption($event->Prefix, 'ListSQLs'); | ||||
$list_sqls[''] .= ' LEFT JOIN '.$item_table.' item_table ON item_table.ResourceId = %1$s.ItemId'; | $list_sqls[''] .= PHP_EOL . 'LEFT JOIN ' . $item_table . ' item_table | ||||
$list_sqls[''] .= ' LEFT JOIN '.$ci_table.' ci ON item_table.ResourceId = ci.ItemResourceId AND ci.PrimaryCat = 1'; | ON item_table.ResourceId = %1$s.ItemId'; | ||||
$list_sqls[''] .= PHP_EOL . 'LEFT JOIN ' . $ci_table . ' ci | |||||
ON item_table.ResourceId = ci.ItemResourceId AND ci.PrimaryCat = 1'; | |||||
$this->Application->setUnitOption($event->Prefix, 'ListSQLs', $list_sqls); | $this->Application->setUnitOption($event->Prefix, 'ListSQLs', $list_sqls); | ||||
// 2. add calculated field | // 2. add calculated field | ||||
$calculated_fields = $this->Application->getUnitOption($event->Prefix, 'CalculatedFields'); | $calculated_fields = $this->Application->getUnitOption($event->Prefix, 'CalculatedFields'); | ||||
$calculated_fields['']['CatalogItemName'] = 'item_table.' . $this->getTitleField($regs[1]); | $calculated_fields['']['CatalogItemName'] = 'item_table.' . $this->getTitleField($regs[1]); | ||||
$calculated_fields['']['CatalogItemId'] = 'item_table.' . $this->Application->getUnitOption($regs[1], 'IDField'); | $calculated_fields['']['CatalogItemId'] = 'item_table.' . $this->Application->getUnitOption($regs[1], 'IDField'); | ||||
$calculated_fields['']['CatalogItemCategory'] = 'ci.CategoryId'; | $calculated_fields['']['CatalogItemCategory'] = 'ci.CategoryId'; | ||||
$this->Application->setUnitOption($event->Prefix, 'CalculatedFields', $calculated_fields); | $this->Application->setUnitOption($event->Prefix, 'CalculatedFields', $calculated_fields); | ||||
Show All 38 Lines |