Changeset View
Changeset View
Standalone View
Standalone View
core/units/reviews/reviews_event_handler.php
Show First 20 Lines • Show All 577 Lines • ▼ Show 20 Line(s) | |||||
{ | { | ||||
parent::OnAfterConfigRead($event); | parent::OnAfterConfigRead($event); | ||||
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'); | ||||
$item_table_on = 'item_table.ResourceId = %1$s.ItemId'; | |||||
$ci_table = $this->Application->getUnitOption('ci', 'TableName'); | $ci_table = $this->Application->getUnitOption('ci', 'TableName'); | ||||
$ci_table_on = 'item_table.ResourceId = ci.ItemResourceId AND ci.PrimaryCat = 1'; | |||||
$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 ON ' . $item_table_on; | ||||
$list_sqls[''] .= ' LEFT JOIN '.$ci_table.' ci ON item_table.ResourceId = ci.ItemResourceId AND ci.PrimaryCat = 1'; | $list_sqls[''] .= PHP_EOL . ' LEFT JOIN ' . $ci_table . ' ci ON ' . $ci_table_on; | ||||
$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 29 Lines | |||||
*/ | */ | ||||
protected function OnSetPerPage(kEvent $event) | protected function OnSetPerPage(kEvent $event) | ||||
{ | { | ||||
parent::OnSetPerPage($event); | parent::OnSetPerPage($event); | ||||
$parent_prefix = $event->Application->getUnitOption($event->Prefix, 'ParentPrefix'); | $parent_prefix = $event->Application->getUnitOption($event->Prefix, 'ParentPrefix'); | ||||
$event->SetRedirectParam('pass', 'm,' . $event->getPrefixSpecial() . ',' . $parent_prefix); | $event->SetRedirectParam('pass', 'm,' . $event->getPrefixSpecial() . ',' . $parent_prefix); | ||||
} | } | ||||
} | } | ||||
Lint: Generic.WhiteSpace.ScopeIndent.IncorrectExact: Line indented incorrectly; expected 0 tabs, found 1 | |||||
Expected 0 spaces before closing brace; 4 found Lint: CodingStandard.Classes.ClassDeclaration.SpaceBeforeCloseBrace: Expected 0 spaces before closing brace; 4 found | |||||
No newline at end of file |
Line indented incorrectly; expected 0 tabs, found 1