/** * Build an instance of a renderer from a row data. * * This row data comes from the session, the db, xml, ... and contains all * data describing the renderer. * * @param array $row the row identifing a report * @param Tracker_Report $report the report of the renderer * * @return Tracker_Report_Renderer null if type is unknown */ protected function getInstanceFromRow($row, $report, $store_in_session = true) { if ($store_in_session) { $this->report_session = new Tracker_Report_Session($report->id); $this->report_session->changeSessionNamespace('renderers'); } if (!isset($this->renderers[$row['id']]) || $row['id'] == 0) { $instance = null; switch ($row['renderer_type']) { case Tracker_Report_Renderer::TABLE: //First retrieve specific properties of the renderer that are not saved in the generic table if (!isset($row['chunksz']) || !isset($row['multisort'])) { $row['chunksz'] = 15; $row['multisort'] = 0; $table_row = $this->getTableDao()->searchByRendererId($row['id'])->getRow(); if ($table_row) { $row['chunksz'] = $table_row['chunksz']; $row['multisort'] = $table_row['multisort']; } } //Build the instance from the row $instance = new Tracker_Report_Renderer_Table($row['id'], $report, $row['name'], $row['description'], $row['rank'], $row['chunksz'], $row['multisort']); if ($store_in_session) { $instance->initiateSession(); } //Add the columns info to the table if any if (empty($row['columns'])) { $instance->getColumns(); } else { $instance->setColumns($row['columns']); } if ($store_in_session) { $instance->storeColumnsInSession(); } //Add the sort info to the table if any if (isset($row['sort'])) { $instance->setSort($row['sort']); if ($store_in_session) { $this->report_session->set("{$row['id']}.sort", $row['sort']); } } break; case Tracker_Report_Renderer::BOARD: //Not yet implemented break; default: $this->getEventManager()->processEvent('tracker_report_renderer_instance', array('instance' => &$instance, 'type' => $row['renderer_type'], 'row' => $row, 'report' => $report, 'store_in_session' => $store_in_session)); break; } $this->renderers[$row['id']] = $instance; if ($instance) { if ($store_in_session) { //override the row in the current session //do not traverse the row with a foreach since some info should not be put in the session // (like SimpleXMLElement during an xml import) //Furthermore, let the plugins set their own properties in the session $this->report_session->set("{$row['id']}.id", $row['id']); $this->report_session->set("{$row['id']}.name", $row['name']); $this->report_session->set("{$row['id']}.description", $row['description']); $this->report_session->set("{$row['id']}.rank", $row['rank']); $this->report_session->set("{$row['id']}.renderer_type", $row['renderer_type']); } } } return $this->renderers[$row['id']]; }