function forum_show_a_nested_message($result, $row = 0) { /* accepts a database result handle to display a single message in the format appropriate for the nested messages second param is which row in that result set to use */ global $Language; $g_id = db_result($result, $row, 'group_id'); if ($g_id == $GLOBALS['sys_news_group']) { $f_id = db_result($result, $row, 'group_forum_id'); $gr = db_query("SELECT group_id FROM news_bytes WHERE forum_id=" . db_ei($f_id)); $g_id = db_result($gr, 0, 'group_id'); } $poster = UserManager::instance()->getUserByUserName(db_result($result, $i, 'user_name')); $ret_val = ' <TABLE BORDER="0" WIDTH="100%"> <TR> <TD class="thread" NOWRAP>' . $Language->getText('forum_forum', 'by') . ': ' . UserHelper::instance()->getLinkOnUser($poster) . '<BR><A HREF="/forum/message.php?msg_id=' . db_result($result, $row, 'msg_id') . '">' . '<IMG SRC="' . util_get_image_theme("msg.png") . '" BORDER=0 HEIGHT=12 WIDTH=10> ' . db_result($result, $row, 'subject') . ' [ ' . $Language->getText('forum_forum', 'reply') . ' ]</A> ' . '<BR>' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), db_result($result, $row, 'date')) . ' </TD> </TR> <TR> <TD> ' . util_make_links(nl2br(db_result($result, $row, 'body')), $g_id) . ' </TD> </TR>'; $crossref_fact = new CrossReferenceFactory(db_result($result, $row, 'msg_id'), ReferenceManager::REFERENCE_NATURE_FORUMMESSAGE, $g_id); $crossref_fact->fetchDatas(); if ($crossref_fact->getNbReferences() > 0) { $ret_val .= '<tr>'; $ret_val .= ' <td class="forum_reference_separator">'; $ret_val .= ' <b> ' . $Language->getText('cross_ref_fact_include', 'references') . '</b>'; $ret_val .= $crossref_fact->getHTMLDisplayCrossRefs(); $ret_val .= ' </td>'; $ret_val .= '</tr>'; } $ret_val .= ' <tr> <td> </td> </tr> </TABLE>'; return $ret_val; }
/** * Display the artifact * * @param ro: read only parameter - Display mode or update mode * @param pv: printer version * * @return void */ function display($ro, $pv, $user_id) { global $art_field_fact, $art_fieldset_fact, $sys_max_size_attachment, $Language; $hp = Codendi_HTMLPurifier::instance(); $fields_per_line = 2; // the column number is the number of field per line * 2 (label + value) // + the number of field per line -1 (a blank column between each pair "label-value" to give more space) $columns_number = $fields_per_line * 2 + ($fields_per_line - 1); $max_size = 40; $group = $this->ArtifactType->getGroup(); $group_artifact_id = $this->ArtifactType->getID(); $group_id = $group->getGroupId(); $result_fields = $art_field_fact->getAllUsedFields(); $result_fieldsets = $art_fieldset_fact->getAllFieldSetsContainingUsedFields(); $summary = $this->getValue('summary'); echo '<div id="tracker_toolbar_specific">'; if ($this->ArtifactType->allowsCopy()) { echo "<A HREF='?func=copy&aid=" . (int) $this->getID() . "&group_id=" . (int) $group_id . "&atid=" . (int) $group_artifact_id . "'><img src=\"" . util_get_image_theme("ic/copy.png") . "\" /> " . $Language->getText('tracker_include_artifact', 'copy_art') . "</A>"; } echo " <A HREF='?func=detail&aid=" . (int) $this->getID() . "&group_id=" . (int) $group_id . "&atid=" . (int) $group_artifact_id . "&pv=1' target='_blank'><img src='" . util_get_image_theme("ic/printer.png") . "' border='0'> " . $Language->getText('global', 'printer_version') . "</A>"; echo '</div>' . PHP_EOL; echo '<div id="tracker_toolbar_clear"></div>' . PHP_EOL; $artTitle = '[ ' . $hp->purify($this->ArtifactType->getItemName(), CODENDI_PURIFIER_CONVERT_HTML); $field_artifact_id = $result_fields['artifact_id']; if ($field_artifact_id->userCanRead($group_id, $group_artifact_id, $user_id)) { $artTitle .= " #" . $hp->purify($this->getID(), CODENDI_PURIFIER_CONVERT_HTML); } $artTitle .= ' ] ' . $hp->purify(util_unconvert_htmlspecialchars($summary), CODENDI_PURIFIER_CONVERT_HTML); // First display some internal fields echo ' <FORM ACTION="" METHOD="POST" enctype="multipart/form-data" NAME="artifact_form"> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="' . $sys_max_size_attachment . '">'; if ($ro) { echo '<INPUT TYPE="HIDDEN" NAME="func" VALUE="postaddcomment">'; } else { echo '<INPUT TYPE="HIDDEN" NAME="func" VALUE="postmod">'; } echo ' <INPUT TYPE="HIDDEN" NAME="artifact_timestamp" VALUE="' . time() . '"> <INPUT TYPE="HIDDEN" NAME="group_id" VALUE="' . (int) $group_id . '"> <INPUT TYPE="HIDDEN" NAME="group_artifact_id" VALUE="' . (int) $group_artifact_id . '"> <INPUT TYPE="HIDDEN" NAME="atid" VALUE="' . (int) $group_artifact_id . '"> <INPUT TYPE="HIDDEN" NAME="artifact_id" VALUE="' . (int) $this->getID() . '"> <INPUT TYPE="HIDDEN" NAME="aid" VALUE="' . (int) $this->getID() . '">'; echo '<TABLE><TR><TD class="artifact">'; $html = ''; $html .= '<TABLE width="100%"><TR>'; $pm = ProjectManager::instance(); // Now display the variable part of the field list (depend on the project) foreach ($result_fieldsets as $fieldset_id => $result_fieldset) { // this variable will tell us if we have to display the fieldset or not (if there is at least one field to display or not) $display_fieldset = false; $fieldset_html = ''; $i = 0; $fields_in_fieldset = $result_fieldset->getAllUsedFields(); while (list($key, $field) = each($fields_in_fieldset)) { if ($field->getName() != 'comment_type_id' && $field->getName() != 'artifact_id') { $field_html = $this->_getFieldLabelAndValueForUser($group_id, $group_artifact_id, $field, $user_id, $pv); if ($field_html) { // if the user can read at least one field, we can display the fieldset this field is within $display_fieldset = true; list($sz, ) = explode("/", $field->getDisplaySize()); // Details field must be on one row if ($sz > $max_size || $field->getName() == 'details') { $fieldset_html .= "\n<TR>" . '<TD align="left" valign="top" width="10%" nowrap="nowrap">' . $field_html['label'] . '</td>' . '<TD valign="top" width="90%" colspan="' . ($columns_number - 1) . '">' . $field_html['value'] . '</TD>' . "\n</TR>"; $i = 0; } else { $fieldset_html .= $i % $fields_per_line ? '' : "\n<TR>"; $fieldset_html .= '<TD align="left" valign="top" width="10%" nowrap="nowrap">' . $field_html['label'] . '</td>' . '<TD width="38%" valign="top">' . $field_html['value'] . '</TD>'; $i++; // if the line is not full, we add a additional column to give more space $fieldset_html .= $i % $fields_per_line ? '<td class="artifact_spacer" width="4%"> </td>' : "\n</TR>"; } } } } // while // We display the fieldset only if there is at least one field inside that we can display if ($display_fieldset) { //$html .= '<TR><TD COLSPAN="'.(int)$columns_number.'"> </TD></TR>'; $html .= '<TR class="boxtitle artifact_fieldset"><TD class="left" COLSPAN="' . (int) $columns_number . '"> <span title="' . $hp->purify(SimpleSanitizer::unsanitize($result_fieldset->getDescriptionText()), CODENDI_PURIFIER_CONVERT_HTML) . '">' . $hp->purify(SimpleSanitizer::unsanitize($result_fieldset->getLabel()), CODENDI_PURIFIER_CONVERT_HTML) . '</span></TD></TR>'; $html .= $fieldset_html; } } $html .= '<tr><td><font color="red">*</font>: ' . $Language->getText('tracker_include_type', 'fields_requ') . '</td></tr></TABLE>'; echo $this->_getSection('artifact_section_details', $artTitle, $html, true); if (!$ro) { echo '<div style="text-align:center"><INPUT CLASS="btn btn-primary" TYPE="SUBMIT" NAME="SUBMIT" VALUE="' . $Language->getText('tracker_include_artifact', 'submit') . '"></div>'; } // // Followups comments // $html = ''; $html .= '<script type="text/javascript">'; $html .= "var tracker_comment_togglers = {};\n function tracker_reorder_followups() {\n var element = \$('artifact_section_followups');\n if (element) {\n element.cleanWhitespace();\n var elements = [];\n var len = element.childNodes.length;\n for(var i = len - 1 ; i >= 0 ; --i) {\n elements.push(Element.remove(element.childNodes[i]));\n }\n for(var i = 0 ; i < len ; ++i) {\n element.appendChild(elements[i]);\n }\n }\n }"; $html .= '</script>'; $html .= '<div>'; if (!$ro) { if (db_numrows($this->ArtifactType->getCannedResponses())) { $html .= '<p><b>' . $Language->getText('tracker_include_artifact', 'use_canned') . '</b> '; $html .= $this->ArtifactType->cannedResponseBox(); $html .= '</p>'; } $field = $art_field_fact->getFieldFromName('comment_type_id'); if ($field && $field->isUsed() && db_numrows($field->getFieldPredefinedValues($group_artifact_id)) > 1) { $field_html = new ArtifactFieldHtml($field); $html .= '<P><B>' . $Language->getText('tracker_include_artifact', 'comment_type') . '</B>' . $field_html->fieldBox('', $group_artifact_id, $field->getDefaultValue(), true, $Language->getText('global', 'none')) . '<BR>'; } $html .= '<b>' . $Language->getText('tracker_include_artifact', 'add_comment') . '</b>'; $html .= '<DIV ID="tracker_artifact_comment_label"></DIV>'; $html .= '<TEXTAREA NAME="comment" id="tracker_artifact_comment" ROWS="10" style="width:700px;" WRAP="SOFT"></TEXTAREA>'; } else { if ($pv == 0) { $html .= '<b>' . $Language->getText('tracker_include_artifact', 'add_comment') . '</b>'; // Non authenticated user can submit only in text format //$html .= '<DIV ID="tracker_artifact_comment_label"></DIV>'; $html .= '<TEXTAREA NAME="comment" id="tracker_artifact_comment" ROWS="10" style="width:700px" WRAP="SOFT"></TEXTAREA>'; } } if (!user_isloggedin() && $pv == 0) { $html .= $Language->getText('tracker_include_artifact', 'not_logged_in', '/account/login.php?return_to=' . urlencode($_SERVER['REQUEST_URI'])); $html .= '<br><input type="text" name="email" maxsize="100" size="50"/><p>'; } $html .= '</div>'; $html .= $this->showFollowUpComments($group_id, $pv); $title = $Language->getText('tracker_include_artifact', 'follow_ups') . ' '; $title .= '<script type="text/javascript">'; $title .= 'document.write(\'<a href="#reorder" onclick="tracker_reorder_followups();new Ajax.Request(\\\'invert_comments_order.php\\\'); return false;" title="Invert order of the follow-ups">[↓↑]</a>\');'; $title .= '</script>'; $title .= ' <a href="/tracker/?func=rss&aid=' . (int) $this->getId() . '&atid=' . (int) $this->ArtifactType->getID() . '&group_id=' . (int) $this->ArtifactType->getGroupId() . '" '; $hp =& Codendi_HTMLPurifier::instance(); $title .= ' title="' . $hp->purify(util_unconvert_htmlspecialchars($group->getPublicName()) . ' ' . SimpleSanitizer::unsanitize($this->ArtifactType->getName()) . ' #' . $this->getId() . ' - ' . util_unconvert_htmlspecialchars($this->getValue('summary')), CODENDI_PURIFIER_CONVERT_HTML) . ' - ' . $Language->getText('tracker_include_artifact', 'follow_ups') . '">'; $title .= '[xml]</a> '; if ($pv == 0) { $title .= help_button('tracker-v3.html#comments') . ' '; } echo $this->_getSection('artifact_section_followups', $title, $html, true); if (user_get_preference('tracker_comment_invertorder')) { echo '<script type="text/javascript">tracker_reorder_followups();</script>'; } // // CC List // $html = ''; if ($pv == 0) { $html .= $Language->getText('tracker_include_artifact', 'fill_cc_list_msg'); $html .= $Language->getText('tracker_include_artifact', 'fill_cc_list_lbl'); $html .= '<textarea type="text" name="add_cc" id="tracker_cc" rows="2" cols="60" wrap="soft"></textarea>'; $html .= '<B> ' . $Language->getText('tracker_include_artifact', 'fill_cc_list_cmt') . ": </b>"; $html .= '<input type="text" name="cc_comment" size="40" maxlength="255">'; } $html .= $this->showCCList($group_id, $group_artifact_id, false, $pv); echo $this->_getSection('artifact_section_cc', $Language->getText('tracker_include_artifact', 'cc_list') . ' ' . ($pv == 0 ? help_button('tracker-v3.html#cc-list') : ''), $html, db_numrows($this->getCCList()), db_numrows($this->getCCList()) ? '' : '<div>' . $GLOBALS['Language']->getText('tracker_include_artifact', 'cc_empty') . '</div>'); // // File attachments // $html = ''; if ($pv == 0) { $html .= '<input type="file" name="input_file" size="40">'; $html .= $Language->getText('tracker_include_artifact', 'upload_file_msg', formatByteToMb($sys_max_size_attachment)); $html .= $Language->getText('tracker_include_artifact', 'upload_file_desc'); $html .= '<input type="text" name="file_description" size="60" maxlength="255">'; } $html .= $this->showAttachedFiles($group_id, $group_artifact_id, false, $pv); echo $this->_getSection('artifact_section_attachments', $Language->getText('tracker_include_artifact', 'attachment') . ' ' . ($pv == 0 ? help_button('tracker-v3.html#artifact-attachments') : ''), $html, db_numrows($this->getAttachedFiles()), db_numrows($this->getAttachedFiles()) ? '' : '<div>' . $GLOBALS['Language']->getText('tracker_include_artifact', 'no_file_attached') . '</div>'); // // Artifact dependencies // $html = '<B>' . $Language->getText('tracker_include_artifact', 'depend_on') . '</B><BR><P>'; if (!$ro) { $html .= ' <B>' . $Language->getText('tracker_include_artifact', 'aids') . '</B> <input type="text" name="artifact_id_dependent" size="20" maxlength="255"> <span style="color:#666">' . $Language->getText('tracker_include_artifact', 'fill') . '</span><p>'; } $html .= $this->showDependencies($group_id, $group_artifact_id, false, $pv); $html .= ' <P><B>' . $Language->getText('tracker_include_artifact', 'dependent_on') . '</B><BR> <P>'; $html .= $this->showInverseDependencies($group_id, $group_artifact_id); echo $this->_getSection('artifact_section_dependencies', $Language->getText('tracker_include_artifact', 'dependencies') . ' ' . ($pv == 0 ? help_button('tracker-v3.html#artifact-dependencies') : ''), $html, db_numrows($this->getDependencies()) || db_numrows($this->getInverseDependencies()), db_numrows($this->getDependencies()) || db_numrows($this->getInverseDependencies()) ? '' : '<div>' . $Language->getText('tracker_include_artifact', 'dep_list_empty') . '</div>'); // // Artifact Cross References // $html = ''; $crossref_fact = new CrossReferenceFactory($this->getID(), ReferenceManager::REFERENCE_NATURE_ARTIFACT, $group_id); $crossref_fact->fetchDatas(); $html .= $crossref_fact->getHTMLDisplayCrossRefs(); echo $this->_getSection('artifact_section_references', $Language->getText('cross_ref_fact_include', 'references') . ' ' . ($pv == 0 ? help_button('tracker-v3.html#artifact-cross-referencing') : ''), $html, $crossref_fact->getNbReferences(), $crossref_fact->getNbReferences() ? '' : '<div>' . $Language->getText('tracker_include_artifact', 'ref_list_empty') . '</div>'); // // Artifact permissions // if ($this->ArtifactType->userIsAdmin()) { $checked = ''; if ($this->useArtifactPermissions()) { $checked = 'checked="checked"'; } $html = ''; $html .= '<p>'; $html .= '<label class="checkbox" for="use_artifact_permissions"><input type="hidden" name="use_artifact_permissions_name" value="0" />'; $html .= '<input type="checkbox" name="use_artifact_permissions_name" id="use_artifact_permissions" value="1" ' . $checked . ' />'; $html .= $GLOBALS['Language']->getText('tracker_include_artifact', 'permissions_label') . '</label>'; $html .= '</p>'; $html .= permission_fetch_selection_field('TRACKER_ARTIFACT_ACCESS', $this->getId(), $group_id); $html .= '<script type="text/javascript">'; $html .= "\n document.observe('dom:loaded', function() {\n if ( ! \$('use_artifact_permissions').checked) {\n \$('ugroups').disable();\n }\n \$('use_artifact_permissions').observe('click', function(evt) {\n if (this.checked) {\n \$('ugroups').enable();\n } else {\n \$('ugroups').disable();\n }\n });\n });\n </script>"; echo $this->_getSection('artifact_section_permissions', $Language->getText('tracker_include_artifact', 'permissions') . ' ' . ($pv == 0 ? help_button('tracker-v3.html#permissions-on-artifacts') : ''), $html, $checked, $checked ? '' : $GLOBALS['Language']->getText('tracker_include_artifact', 'permissions_not_restricted')); } // // History // $is_there_history = db_numrows($this->getHistory()); echo $this->_getSection('artifact_section_history', $Language->getText('tracker_include_artifact', 'change_history') . ' ' . ($pv == 0 ? help_button('tracker-v3.html#artifact-history') : ''), $this->showHistory($group_id, $group_artifact_id), !$is_there_history); // // Final submit button // if ($pv == 0) { echo '<div style="text-align:center"><INPUT CLASS="btn btn-primary" TYPE="SUBMIT" NAME="SUBMIT" VALUE="' . $Language->getText('tracker_include_artifact', 'submit') . '"></div>'; } echo '</td></tr>'; echo '</table>'; echo '</form>'; user_set_preference('tracker_' . $this->ArtifactType->getId() . '_artifact_' . $this->getId() . '_last_visit', time()); }
function displayPage(&$request, $template = false) { global $WikiTheme, $pv; $pagename = $request->getArg('pagename'); $version = $request->getArg('version'); $page = $request->getPage(); if ($version) { $revision = $page->getRevision($version); if (!$revision) { NoSuchRevision($request, $page, $version); } } else { $revision = $page->getCurrentRevision(); } if (isSubPage($pagename)) { $pages = explode(SUBPAGE_SEPARATOR, $pagename); $last_page = array_pop($pages); // deletes last element from array as side-effect $pageheader = HTML::span(HTML::a(array('href' => WikiURL($pages[0]), 'class' => 'pagetitle'), $WikiTheme->maybeSplitWikiWord($pages[0] . SUBPAGE_SEPARATOR))); $first_pages = $pages[0] . SUBPAGE_SEPARATOR; array_shift($pages); foreach ($pages as $p) { if ($pv != 2) { //Add the Backlink in page title $pageheader->pushContent(HTML::a(array('href' => WikiURL($first_pages . $p), 'class' => 'backlinks'), $WikiTheme->maybeSplitWikiWord($p . SUBPAGE_SEPARATOR))); } else { // Remove Backlinks $pageheader->pushContent(HTML::h1($pagename)); } $first_pages .= $p . SUBPAGE_SEPARATOR; } if ($pv != 2) { $backlink = HTML::a(array('href' => WikiURL($pagename, array('action' => _("BackLinks"))), 'class' => 'backlinks'), $WikiTheme->maybeSplitWikiWord($last_page)); $backlink->addTooltip(sprintf(_("BackLinks for %s"), $pagename)); } else { $backlink = HTML::h1($pagename); } $pageheader->pushContent($backlink); } else { if ($pv != 2) { $pageheader = HTML::a(array('href' => WikiURL($pagename, array('action' => _("BackLinks"))), 'class' => 'backlinks'), $WikiTheme->maybeSplitWikiWord($pagename)); $pageheader->addTooltip(sprintf(_("BackLinks for %s"), $pagename)); } else { $pageheader = HTML::h1($pagename); //Remove Backlinks } if ($request->getArg('frame')) { $pageheader->setAttr('target', '_top'); } } // {{{ Codendi hook to insert stuff between navbar and header $eM =& EventManager::instance(); $ref_html = ''; $crossref_fact = new CrossReferenceFactory($pagename, ReferenceManager::REFERENCE_NATURE_WIKIPAGE, GROUP_ID); $crossref_fact->fetchDatas(); if ($crossref_fact->getNbReferences() > 0) { $ref_html .= '<h3>' . $GLOBALS['Language']->getText('cross_ref_fact_include', 'references') . '</h3>'; $ref_html .= $crossref_fact->getHTMLDisplayCrossRefs(); } $additional_html = false; $eM->processEvent('wiki_before_content', array('html' => &$additional_html, 'group_id' => GROUP_ID, 'wiki_page' => $pagename)); if ($additional_html) { $beforeHeader = HTML(); $beforeHeader->pushContent($additional_html); $beforeHeader->pushContent(HTML::raw($ref_html)); $toks['BEFORE_HEADER'] = $beforeHeader; } else { $beforeHeader = HTML(); $beforeHeader->pushContent(HTML::raw($ref_html)); $toks['BEFORE_HEADER'] = $beforeHeader; } // }}} /Codendi hook $pagetitle = SplitPagename($pagename); if ($redirect_from = $request->getArg('redirectfrom')) { $redirect_message = HTML::span(array('class' => 'redirectfrom'), fmt("(Redirected from %s)", RedirectorLink($redirect_from))); // abuse the $redirected template var for some status update notice } elseif ($request->getArg('errormsg')) { $redirect_message = $request->getArg('errormsg'); $request->setArg('errormsg', false); } $request->appendValidators(array('pagerev' => $revision->getVersion(), '%mtime' => $revision->get('mtime'))); /* // FIXME: This is also in the template... if ($request->getArg('action') != 'pdf' and !headers_sent()) { // FIXME: enable MathML/SVG/... support if (ENABLE_XHTML_XML and (!isBrowserIE() and strstr($request->get('HTTP_ACCEPT'),'application/xhtml+xml'))) header("Content-Type: application/xhtml+xml; charset=" . $GLOBALS['charset']); else header("Content-Type: text/html; charset=" . $GLOBALS['charset']); } */ $page_content = $revision->getTransformedContent(); // if external searchengine (google) referrer, highlight the searchterm // FIXME: move that to the transformer? // OR: add the searchhightplugin line to the content? if ($result = isExternalReferrer($request)) { if (DEBUG and !empty($result['query'])) { //$GLOBALS['SearchHighlightQuery'] = $result['query']; /* simply add the SearchHighlight plugin to the top of the page. This just parses the wikitext, and doesn't highlight the markup */ include_once 'lib/WikiPlugin.php'; $loader = new WikiPluginLoader(); $xml = $loader->expandPI('<' . '?plugin SearchHighlight s="' . $result['query'] . '"?' . '>', $request, $markup); if ($xml and is_array($xml)) { foreach (array_reverse($xml) as $line) { array_unshift($page_content->_content, $line); } array_unshift($page_content->_content, HTML::div(_("You searched for: "), HTML::strong($result['query']))); } if (0) { /* Parse the transformed (mixed HTML links + strings) lines? This looks like overkill. */ require_once "lib/TextSearchQuery.php"; $query = new TextSearchQuery($result['query']); $hilight_re = $query->getHighlightRegexp(); //$matches = preg_grep("/$hilight_re/i", $revision->getContent()); // FIXME! for ($i = 0; $i < count($page_content->_content); $i++) { $found = false; $line = $page_content->_content[$i]; if (is_string($line)) { while (preg_match("/^(.*?)({$hilight_re})/i", $line, $m)) { $found = true; $line = substr($line, strlen($m[0])); $html[] = $m[1]; // prematch $html[] = HTML::strong(array('class' => 'search-term'), $m[2]); // match } } if ($found) { $html[] = $line; // postmatch $page_content->_content[$i] = HTML::span(array('class' => 'search-context'), $html); } } } } } $toks['CONTENT'] = new Template('browse', $request, $page_content); $toks['TITLE'] = $pagetitle; // <title> tag $toks['HEADER'] = $pageheader; // h1 with backlink $toks['revision'] = $revision; if (!empty($redirect_message)) { $toks['redirected'] = $redirect_message; } $toks['ROBOTS_META'] = 'index,follow'; $toks['PAGE_DESCRIPTION'] = $page_content->getDescription(); $toks['PAGE_KEYWORDS'] = GleanKeywords($page); if (!$template) { $template = new Template('html', $request); } $template->printExpansion($toks); $page->increaseHitCount(); if ($request->getArg('action') != 'pdf') { $request->checkValidators(); } flush(); }
function build_number() { $request =& HTTPRequest::instance(); $group_id = $request->get('group_id'); if ($request->exist('build')) { $build_id = $request->get('build'); } else { $build_id = $request->get('build_id'); } $job_dao = new PluginHudsonJobDao(CodendiDataAccess::instance()); if ($request->exist('job_id')) { $job_id = $request->get('job_id'); $dar = $job_dao->searchByJobID($job_id); } elseif ($request->exist('job')) { // used for references (build #MyJob/175 or job #myproject:MyJob/175 where 175 is the build number required) $job_name = $request->get('job'); $dar = $job_dao->searchByJobName($job_name, $group_id); } else { // used for references (build #175 where 175 is the build number required) // If no job or project is specified, we check if there is only one job associated to the current project and we assume it is this job. $dar = $job_dao->searchByGroupID($group_id); if ($dar->rowCount() != 1) { $dar = null; } } if ($dar && $dar->valid()) { $row = $dar->current(); $crossref_fact = new CrossReferenceFactory($row['name'] . '/' . $build_id, 'hudson_build', $group_id); $crossref_fact->fetchDatas(); if ($crossref_fact->getNbReferences() > 0) { echo '<b> ' . $GLOBALS['Language']->getText('cross_ref_fact_include', 'references') . '</b>'; $crossref_fact->DisplayCrossRefs(); } $this->_display_iframe($row['job_url'] . '/' . $build_id . '/'); } else { echo '<span class="error">' . $GLOBALS['Language']->getText('plugin_hudson', 'error_object_not_found') . '</span>'; } }
function show_commit_details($result) { global $group_id, $commit_id, $Language; /* Accepts a result set from the commits table. Should include all columns from the table, and it should be joined to USER to get the user_name. */ $rows = db_numrows($result); $url = "/cvs/?func=detailcommit&commit_id={$commit_id}&group_id={$group_id}&order="; $list_log = '<pre>' . util_make_links(util_line_wrap(db_result($result, 0, 'description')), $group_id) . '</pre>'; if ($commit_id) { $hdr = '[' . $Language->getText('cvs_commit_utils', 'commit') . $commit_id . '] - '; } else { $hdr = $Language->getText('cvs_commit_utils', 'checkin') . ' '; } echo '<h2>' . $hdr . uniformat_date($GLOBALS['Language']->getText('system', 'datefmt'), db_result($result, 0, 'c_when')) . '</h2></h2>'; echo '<table WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="2"><tr class="' . util_get_alt_row_color(0) . '"><td>' . $list_log . '</td></tr></table>'; $crossref_fact = new CrossReferenceFactory($commit_id, ReferenceManager::REFERENCE_NATURE_CVSCOMMIT, $group_id); $crossref_fact->fetchDatas(); if ($crossref_fact->getNbReferences() > 0) { echo '<h3> ' . $Language->getText('cross_ref_fact_include', 'references') . '</h3>'; $crossref_fact->DisplayCrossRefs(); } echo '<h3>' . $Language->getText('cvs_commit_utils', 'impacted_file') . '</h3>'; $title_arr = array(); $title_arr[] = $Language->getText('cvs_commit_utils', 'file'); $title_arr[] = $Language->getText('cvs_commit_utils', 'rev'); $title_arr[] = $Language->getText('cvs_commit_utils', 'branch'); $title_arr[] = $Language->getText('cvs_commit_utils', 'type'); $title_arr[] = $Language->getText('cvs_commit_utils', 'added_line'); $title_arr[] = $Language->getText('cvs_commit_utils', 'removed_line'); $links_arr = array(); $links_arr[] = $url . 'filename'; $links_arr[] = $url . 'revision'; $links_arr[] = $url . 'branch'; $links_arr[] = $url . 'type'; $links_arr[] = $url . 'addedlines'; $links_arr[] = $url . 'removedlines'; echo html_build_list_table_top($title_arr, $links_arr); for ($i = 0; $i < $rows; $i++) { $commit_id = db_result($result, $i, 'id'); $type = db_result($result, $i, 'type'); $added = db_result($result, $i, 'addedlines'); $removed = db_result($result, $i, 'removedlines'); $revision = db_result($result, $i, 'revision'); $filename = db_result($result, $i, 'dir') . '/' . db_result($result, $i, 'file'); $type_text = $Language->getText('cvs_commit_utils', strtolower($type)); if ($type == "Change" && $added == 999 && $removed == 999) { // the default values // back to rcs to complete $repo = db_result($result, $i, 'repository'); $command = "rlog -r" . $revision . " " . $repo . "/" . $filename; $output = array(); exec($command, $output, $ret); $added = 0; $removed = 0; $l = 0; while ($l < count($output)) { // parse the rlog result till getting "state: Exp; lines:" $line = $output[$l]; $l++; if (ereg('state: +Exp; +lines: +\\+([0-9]*) +\\-([0-9]*)$', $line, $na)) { $added = $na[1]; $removed = $na[2]; $sql_up = "UPDATE cvs_checkins SET addedlines=" . $added . ", removedlines=" . $removed . " WHERE repositoryid=" . db_result($result, $i, 'repositoryid') . " AND dirid=" . db_result($result, $i, 'dirid') . " AND fileid=" . db_result($result, $i, 'fileid') . " AND revision=" . $revision; $res = db_query($sql_up); break; } } } if (!$filename) { $filename = ''; } else { if ($type == 'Remove') { $filename = makeCvsDirLink($group_id, db_result($result, $i, 'file'), $filename, db_result($result, $i, 'dir')); $rev_text = ''; } else { // Clean file path to remove duplicate separators $filename = preg_replace('/\\/\\//', '/', $filename); $filename = preg_replace('/\\.\\//', '', $filename); if ($type == 'Change') { // horrible hack to 'guess previous revision' to diff with $prev = explode(".", $revision); $lastIndex = sizeof($prev); $lastIndex = $lastIndex - 1; if ($prev[$lastIndex] != '1') { $prev[$lastIndex] = $prev[$lastIndex] - 1; $previous = join(".", $prev); } else { $index = 0; $new_prev = array(); while ($index <= $lastIndex - 2) { $new_prev[$index] = $prev[$index]; $index++; } $previous = join('.', $new_prev); } $type = makeCvsLink($group_id, $filename, $type_text, '', '&r1=' . $previous . '&r2=' . $revision); } $rev_text = makeCvsLink($group_id, $filename, $revision, $revision, '&view=markup'); $filename = makeCvsLink($group_id, $filename, $filename, '', '&view=log'); } } ##$commits_url = '<A HREF="/commits/download.php/Commits'.$commit_id.'.txt?commit_id='.$id.'">'.$filename.'</a>'; echo ' <TR class="' . util_get_alt_row_color($i) . '">' . '<TD class="small"><b>' . $filename . '</b></TD>' . '<TD class="small">' . $rev_text . '</TD>' . '<TD class="small">' . db_result($result, $i, 'branch') . '</TD>' . '<TD class="small">' . $type . '</TD>' . '<TD class="small">' . $added . '</TD>' . '<TD class="small">' . $removed . '</TD></TR>'; } /* Show extra rows for <-- Prev / Next --> */ echo ' <TR><TD COLSPAN="2" class="small">'; if ($offset > 0) { echo '<A HREF="?func=browse&group_id=' . $group_id . '&set=' . $set . '&offset=' . ($offset - 50) . '"><B>< ' . $Language->getText('global', 'prev') . '</B></A>'; } else { echo ' '; } echo '</TD><TD> </TD><TD COLSPAN="2" class="small">'; if ($rows == 50) { echo '<A HREF="?func=browse&group_id=' . $group_id . '&set=' . $set . '&offset=' . ($offset + 50) . '"><B>' . $Language->getText('global', 'prev') . ' 50 ></B></A>'; } else { echo ' '; } echo '</TD></TR></TABLE>'; }
function svn_utils_show_revision_detail($result, $group_id, $group_name, $commit_id) { global $Language; /* Accepts a result set from the svn_checkins table. Should include all columns from the table, and it should be joined to USER to get the user_name. */ $rows = db_numrows($result); $url = "/svn/?func=detailrevision&commit_id={$commit_id}&group_id={$group_id}&order="; $list_log = '<pre>' . util_make_links(util_line_wrap(db_result($result, 0, 'description')), $group_id) . '</pre>'; $revision = db_result($result, 0, 'revision'); $hdr = '[' . $Language->getText('svn_browse_revision', 'rev') . ' #' . $revision . '] - '; echo '<h2>' . $hdr . format_date($GLOBALS['Language']->getText('system', 'datefmt'), db_result($result, 0, 'date')) . '</h2></h2>'; echo '<table WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="2"><tr class="' . util_get_alt_row_color(0) . '"><td>' . $list_log . '</td></tr></table>'; $crossref_fact = new CrossReferenceFactory($revision, ReferenceManager::REFERENCE_NATURE_SVNREVISION, $group_id); $crossref_fact->fetchDatas(); if ($crossref_fact->getNbReferences() > 0) { echo '<h3> ' . $Language->getText('cross_ref_fact_include', 'references') . '</h3>'; $crossref_fact->DisplayCrossRefs(); } echo '<h3> ' . $Language->getText('svn_utils', 'impacted_files') . '</h3>'; $title_arr = array(); $title_arr[] = $Language->getText('svn_utils', 'file'); $title_arr[] = $Language->getText('svn_browse_revision', 'rev'); $title_arr[] = $Language->getText('svn_utils', 'type'); //$title_arr[]='AddedLines'; To be implemented //$title_arr[]='RemovedLines'; To be implemented $links_arr = array(); $links_arr[] = $url . 'filename'; $links_arr[] = $url . ''; $links_arr[] = $url . 'type'; $pm = ProjectManager::instance(); $project = $pm->getProject($group_id); $root = $project->getUnixName(); echo html_build_list_table_top($title_arr, $links_arr); for ($i = 0; $i < $rows; $i++) { $type = db_result($result, $i, 'type'); $dirname = db_result($result, $i, 'dir'); $filename = db_result($result, $i, 'file'); $fullpath = $dirname . $filename; if ($filename) { // It' a file $viewfile_url = svn_utils_make_viewlink($group_name, $fullpath, $fullpath, "&pathrev={$revision}&view=log"); $viewrev_url = svn_utils_make_viewlink($group_name, $fullpath, $revision, "&revision={$revision}&pathrev={$revision}&view=markup"); } else { // It' a directory $viewfile_url = svn_utils_make_viewlink($group_name, $fullpath, $fullpath, "&pathrev={$revision}"); $viewrev_url = svn_utils_make_viewlink($group_name, $fullpath, $revision, "&pathrev={$revision}&view=log"); } if ($type == 'Change') { $viewtype_url = svn_utils_make_viewlink($group_name, $fullpath, $Language->getText('svn_utils', 'change'), "&r1=" . ($revision - 1) . "&r2={$revision}&diff_format=h&pathrev={$revision}"); } else { if ($type == 'Add') { $viewtype_url = $Language->getText('svn_utils', 'add'); } else { if ($type == 'Delete') { $viewtype_url = $Language->getText('svn_utils', 'del'); } } } echo ' <TR class="' . util_get_alt_row_color($i) . '">' . '<TD class="small"><b>' . $viewfile_url . '</b></TD>' . '<TD class="small" width="10%" align="center">' . $viewrev_url . '</TD>' . '<TD class="small" width="10%" align="center">' . $viewtype_url . '</TD>'; //'<TD class="small">'.$added.'</TD>'. // To be done //'<TD class="small">'.$removed.'</TD></TR>'; // To be done } echo '</TD></TR></TABLE>'; }
/** * Fetch the html code to display the field value in tooltip * * @param Tracker_Artifact $artifact * @param Tracker_Artifact_ChangesetValue_Integer $value The changeset value of this field * @return string The html code to display the field value in tooltip */ protected function fetchTooltipValue(Tracker_Artifact $artifact, Tracker_Artifact_ChangesetValue $value = null) { $html = ''; $crossref_fact = new CrossReferenceFactory($artifact->getId(), Tracker_Artifact::REFERENCE_NATURE, $this->getTracker()->getGroupId()); $crossref_fact->fetchDatas(); if ($crossref_fact->getNbReferences()) { $html .= $crossref_fact->getHTMLDisplayCrossRefs($with_links = false, $condensed = true); } else { $html .= '<div>' . $GLOBALS['Language']->getText('plugin_tracker_include_artifact', 'ref_list_empty') . '</div>'; } return $html; }
function forum_header($params) { global $HTML, $group_id, $forum_name, $thread_id, $msg_id, $forum_id, $et, $et_cookie, $Language; $hp = Codendi_HTMLPurifier::instance(); $uh = new UserHelper(); $params['group'] = $group_id; $params['toptab'] = 'forum'; $params['help'] = 'WebForums.html'; /* bastardization for news Show icon bar unless it's a news forum */ if ($group_id == $GLOBALS['sys_news_group']) { //this is a news item, not a regular forum if ($forum_id) { /* Show this news item at the top of the page */ $sql = "SELECT * FROM news_bytes WHERE forum_id=" . db_ei($forum_id); $result = db_query($sql); //backwards shim for all "generic news" that used to be submitted //as of may, "generic news" is not permitted - only project-specific news if (db_result($result, 0, 'group_id') != $GLOBALS['sys_news_group']) { $params['group'] = db_result($result, 0, 'group_id'); $params['toptab'] = 'news'; $group_id = db_result($result, 0, 'group_id'); site_project_header($params); } else { $HTML->header($params); echo ' <H2>' . $GLOBALS['sys_name'] . ' <A HREF="/news/">' . $Language->getText('forum_forum_utils', 'news') . '</A></H2><P>'; } echo '<TABLE><TR><TD VALIGN="TOP">'; if (!$result || db_numrows($result) < 1) { echo ' <h3>' . $Language->getText('forum_forum_utils', 'news_not_found') . '</h3>'; } else { echo ' <B>' . $Language->getText('forum_forum_utils', 'posted_by') . ':</B> ' . $hp->purify($uh->getDisplayNameFromUserId(db_result($result, 0, 'submitted_by')), CODENDI_PURIFIER_CONVERT_HTML) . '<BR> <B>' . $Language->getText('forum_forum', 'date') . ':</B> ' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), db_result($result, 0, 'date')) . '<BR> <B>' . $Language->getText('forum_forum_utils', 'summary') . ':</B><A HREF="/forum/forum.php?forum_id=' . db_result($result, 0, 'forum_id') . '">' . db_result($result, 0, 'summary') . '</A> <P> ' . util_make_links(nl2br(db_result($result, 0, 'details')), $group_id); echo '<P>'; $crossref_fact = new CrossReferenceFactory($forum_id, ReferenceManager::REFERENCE_NATURE_NEWS, $group_id); $crossref_fact->fetchDatas(); if ($crossref_fact->getNbReferences() > 0) { echo '<b> ' . $Language->getText('cross_ref_fact_include', 'references') . '</b>'; $crossref_fact->DisplayCrossRefs(); } } echo '</TD><TD VALIGN="TOP" WIDTH="35%">'; echo $HTML->box1_top($Language->getText('forum_forum_utils', 'proj_latest_news'), 0); echo news_show_latest(db_result($result, 0, 'group_id'), 5, false); echo $HTML->box1_bottom(); echo '</TD></TR></TABLE>'; } } else { //this is just a regular forum, not a news item site_project_header($params); } /* Show horizontal forum links */ if ($forum_id && $forum_name) { echo '<P><H3>' . $Language->getText('forum_forum_utils', 'discuss_forum') . ': <A HREF="/forum/forum.php?forum_id=' . $forum_id . '">' . $forum_name . '</A></H3>'; } if (!isset($params['pv']) || isset($params['pv']) && !$params['pv']) { echo '<P><B>'; $request =& HTTPRequest::instance(); if ($forum_id && user_isloggedin() && !$request->exist('delete')) { if (user_monitor_forum($forum_id, user_getid())) { $msg = $Language->getText('forum_forum_utils', 'stop_monitor'); } else { $msg = $Language->getText('forum_forum_utils', 'monitor'); } echo '<A HREF="/forum/monitor.php?forum_id=' . $forum_id . '">'; echo html_image("ic/monitor_forum.png", array()) . ' ' . $msg . '</A> | '; echo '<A HREF="/forum/monitor_thread.php?forum_id=' . $forum_id . '"> ' . html_image("ic/monitor_thread.png", array()) . $Language->getText('forum_forum_utils', 'monitor_thread') . '</A> | '; echo '<A HREF="/forum/save.php?forum_id=' . $forum_id . '">'; echo html_image("ic/save.png", array()) . ' ' . $Language->getText('forum_forum_utils', 'save_place') . '</A> | '; print ' <a href="forum.php?forum_id=' . $forum_id . '#start_new_thread">'; echo html_image("ic/thread.png", array()) . ' ' . $Language->getText('forum_forum_utils', 'start_thread') . '</A> | '; if (isset($msg_id) && $msg_id) { echo "<A HREF='" . $_SERVER['PHP_SELF'] . "?msg_id={$msg_id}&pv=1'><img src='" . util_get_image_theme("msg.png") . "' border='0'> " . $Language->getText('global', 'printer_version') . "</A> | "; } else { echo "<A HREF='" . $_SERVER['PHP_SELF'] . "?forum_id={$forum_id}&pv=1'><img src='" . util_get_image_theme("msg.png") . "' border='0'> " . $Language->getText('global', 'printer_version') . "</A> | "; } } // The forum admin link is only displayed for the forum moderators if (user_ismember($group_id, 'F2')) { echo ' <A HREF="/forum/admin/?group_id=' . $group_id . '">' . $Language->getText('forum_forum_utils', 'admin') . '</A></B>'; if (isset($params['help']) && $params['help']) { echo ' | '; } } if (isset($params['help']) && $params['help']) { echo help_button($params['help'], false, $Language->getText('global', 'help')); } echo '</B><P>'; } }
if (!$release || !$release->isActive() || !$release->userCanRead()) { exit_error($Language->getText('file_shownotes', 'not_found_err'), $Language->getText('file_shownotes', 'release_not_found')); } else { $hp =& Codendi_HTMLPurifier::instance(); $group_id = $release->getGroupID(); file_utils_header(array('title' => $Language->getText('file_shownotes', 'release_notes'), 'group' => $group_id)); $HTML->box1_top($Language->getText('file_shownotes', 'notes')); echo '<h3>' . $Language->getText('file_shownotes', 'release_name') . ': <A HREF="showfiles.php?group_id=' . $group_id . '">' . $hp->purify($release->getName()) . '</A></H3> <P>'; /* Show preformatted or plain notes/changes */ $purify_level = CODENDI_PURIFIER_BASIC; if ($release->isPreformatted()) { echo '<PRE>' . PHP_EOL; $purify_level = CODENDI_PURIFIER_BASIC_NOBR; } echo '<B>' . $Language->getText('file_shownotes', 'notes') . ':</B>' . PHP_EOL . $hp->purify($release->getNotes(), $purify_level, $group_id) . '<HR NOSHADE SIZE=1>' . '<B>' . $Language->getText('file_shownotes', 'changes') . ':</B>' . PHP_EOL . $hp->purify($release->getChanges(), $purify_level, $group_id); if ($release->isPreformatted()) { echo '</PRE>'; } $crossref_fact = new CrossReferenceFactory($release_id, ReferenceManager::REFERENCE_NATURE_RELEASE, $group_id); $crossref_fact->fetchDatas(); if ($crossref_fact->getNbReferences() > 0) { echo '<hr noshade>'; echo '<b> ' . $Language->getText('cross_ref_fact_include', 'references') . '</b>'; $crossref_fact->DisplayCrossRefs(); } $HTML->box1_bottom(); file_utils_footer(array()); }