/** * Return table attribute html. * * @param BaseElementModel $element * @param string $attribute * * @return string */ public function getTableAttributeHtml(BaseElementModel $element, $attribute) { // First give plugins a chance to set this $pluginAttributeHtml = craft()->plugins->callFirst('getAuditLogTableAttributeHtml', array($element, $attribute), true); // Check if that had a valid result if ($pluginAttributeHtml) { return $pluginAttributeHtml; } // Modify custom attributes switch ($attribute) { // Format dates case 'dateCreated': case 'dateUpdated': return craft()->dateFormatter->formatDateTime($element->{$attribute}); // Return clickable user link // Return clickable user link case 'user': $user = $element->getUser(); return $user ? '<a href="' . $user->getCpEditUrl() . '">' . $user . '</a>' : Craft::t('Guest'); // Return clickable event origin // Return clickable event origin case 'origin': return '<a href="' . preg_replace('/' . craft()->config->get('cpTrigger') . '\\//', '', UrlHelper::getUrl($element->origin), 1) . '">' . $element->origin . '</a>'; // Return view changes button // Return view changes button case 'changes': return '<a class="btn" href="' . UrlHelper::getCpUrl('auditlog/' . $element->id) . '">' . Craft::t('View') . '</a>'; // Default behavior // Default behavior default: return $element->{$attribute}; } }