/** * Return the display data for a moduleId-ItemId pair. * * @param array $data Array with the module data for show (moduleId => itemId). * * @return array Array with 'id', 'moduleId', 'moduleName', 'moduleLabel', * 'firstDisplay', 'secondDisplay' and 'projectId'. */ public function getDisplay($data) { $results = array(); foreach ($data as $moduleId => $content) { $ids = array(); foreach ($content as $id) { $ids[] = (int) $id; } if (!empty($ids)) { $where = sprintf('module_id = %d AND item_id IN (%s)', (int) $moduleId, implode(', ', $ids)); $tmpResult = $this->fetchAll($where)->toArray(); $moduleName = Phprojekt_Module::getModuleName($moduleId); $moduleLabel = Phprojekt::getInstance()->translate(Phprojekt_Module::getModuleLabel($moduleId), null, $moduleName); foreach ($tmpResult as $result) { $index = $moduleId . '-' . $result['item_id']; $results[$index] = array('id' => (int) $result['item_id'], 'moduleId' => (int) $moduleId, 'moduleName' => $moduleName, 'moduleLabel' => $moduleLabel, 'firstDisplay' => $result['first_display'], 'secondDisplay' => $result['second_display'], 'projectId' => (int) $result['project_id']); } foreach ($ids as $id) { $index = $moduleId . '-' . $id; if (!isset($results[$index])) { $results[$index] = array('id' => (int) $id, 'moduleId' => (int) $moduleId, 'moduleName' => Phprojekt_Module::getModuleName($moduleId), 'moduleLabel' => $moduleLabel, 'firstDisplay' => '', 'secondDisplay' => '', 'projectId' => 1); } } } } return array_values($results); }