/** * Compute the content of the widget * * @return String */ public function getContent() { $dao = new Git_LogDao(); $um = UserManager::instance(); $user = $um->getCurrentUser(); $date = $_SERVER['REQUEST_TIME'] - $this->pastDays * 24 * 60 * 60; $result = $dao->getLastPushesRepositories($user->getId(), $date); $content = ''; $project = ''; $dh = new DateHelper(); if ($result && !$result->isError()) { foreach ($result as $entry) { if (!empty($entry['repository_namespace'])) { $namespace = $entry['repository_namespace'] . "/"; } else { $namespace = ''; } $dar = $dao->getLastPushesByUser($user->getId(), $entry['repository_id'], $this->offset, $date); if ($dar && !$dar->isError() && $dar->rowCount() > 0) { if ($project != $entry['group_name']) { if (!empty($project)) { $content .= '</fieldset>'; } $project = $entry['group_name']; $content .= '<fieldset> <legend id="plugin_git_user_pushes_widget_project_' . $project . '" class="' . Toggler::getClassname('plugin_git_user_pushes_widget_project_' . $project) . '"> <span title="' . $GLOBALS['Language']->getText('plugin_git', 'tree_view_project') . '"> <b>' . $project . '</b> </span> </legend> <a href="' . $this->pluginPath . '/index.php?group_id=' . $entry['group_id'] . '">[ ' . $GLOBALS['Language']->getText('plugin_git', 'widget_user_pushes_details') . ' ]</a>'; } $content .= '<fieldset> <legend id="plugin_git_user_pushes_widget_repo_' . $project . $namespace . $entry['repository_name'] . '" class="' . Toggler::getClassname('plugin_git_user_pushes_widget_repo_' . $project . $namespace . $entry['repository_name']) . '"> <span title="' . $GLOBALS['Language']->getText('plugin_git', 'tree_view_repository') . '"> ' . $namespace . $entry['repository_name'] . ' </span> </legend> ' . html_build_list_table_top(array($GLOBALS['Language']->getText('plugin_git', 'tree_view_date'), $GLOBALS['Language']->getText('plugin_git', 'tree_view_commits'))); $i = 0; $hp = Codendi_HTMLPurifier::instance(); foreach ($dar as $row) { $content .= '<tr class="' . html_get_alt_row_color(++$i) . '"> <td><span title="' . $dh->timeAgoInWords($row['push_date'], true) . '">' . $hp->purify(format_date($GLOBALS['Language']->getText('system', 'datefmt'), $row['push_date'])) . '</span></td> <td> <a href="' . $this->pluginPath . '/index.php/' . $entry['group_id'] . '/view/' . $entry['repository_id'] . '/"> ' . $hp->purify($row['commits_number']) . ' </a> </td> </tr>'; } $content .= "</table>\n </fieldset>"; } else { $content .= $GLOBALS['Language']->getText('plugin_git', 'widget_user_pushes_no_content'); } } } else { $content = $GLOBALS['Language']->getText('plugin_git', 'widget_user_pushes_no_content'); } return $content; }