/** * detect object icon by analizing it's data * * object data could have set a custom iconCls in cfg property of the data, * otherwise the icon is determined from it's template * TODO: think about shortcuts * @param array $data object data * @return varchar iconCls */ public static function getIcon(&$data) { if (!empty($data['cfg']) && !empty($data['cfg']['iconCls'])) { return $data['cfg']['iconCls']; } if (empty($data['template_id'])) { return 'icon-none'; } $templates = Templates\SingletonCollection::getInstance(); $templateData = $templates->getTemplate($data['template_id'])->getData(); if (!empty($templateData['iconCls'])) { return $templateData['iconCls']; } switch ($templateData['type']) { case 'object': if (in_array($data['template_id'], Config::get('folder_templates'))) { return 'icon-folder'; } break; case 2: return 'icon-shortcut'; //case break; case 'file': return Files::getIcon($data['name']); break; case 'task': if (@$d['status'] == 3) { return 'icon-task-completed'; } return 'icon-task'; //task break; case 'email': return 'icon-mail'; //Message (email) break; } return 'icon-none'; }
/** * get link to a file to be displayed in comments * @param array $file * @return varchar */ protected static function getFileLink($file) { $rez = ''; if (substr($file['type'], 0, 5) == 'image') { $rez = '<a class="click obj-ref" itemid="' . $file['id'] . '" templateid= "' . $file['template_id'] . '" title="' . $file['name'] . '"><img class="fit-img" src="/' . Config::get('core_name') . '/download/' . $file['id'] . '/" /></a>'; } else { $rez = '<a class="click obj-ref icon-padding ' . \CB\Files::getIcon($file['name']) . '" itemid="' . $file['id'] . '" templateid= "' . $file['template_id'] . '">' . $file['name'] . '</a>'; } return $rez; }