function getContent()
 {
     $crf = new CrossReferenceFactory($this->item->getId(), ReferenceManager::REFERENCE_NATURE_DOCUMENT, $this->item->getGroupId());
     $crf->fetchDatas();
     $content = $crf->getHTMLDisplayCrossRefs();
     return $content;
 }
Ejemplo n.º 2
0
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> &nbsp; ' . '<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;
}
Ejemplo n.º 3
0
 /**
  * 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") . "\" />&nbsp;" . $Language->getText('tracker_include_artifact', 'copy_art') . "</A>";
     }
     echo "&nbsp;&nbsp;<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'>&nbsp;" . $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%">&nbsp;</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.'">&nbsp</TD></TR>';
             $html .= '<TR class="boxtitle artifact_fieldset"><TD class="left" COLSPAN="' . (int) $columns_number . '">&nbsp;<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>&nbsp;';
             $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">[&darr;&uarr;]</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>&nbsp;&nbsp;&nbsp;' . $Language->getText('tracker_include_artifact', 'fill_cc_list_cmt') . ":&nbsp</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>&nbsp;
                 <input type="text" name="artifact_id_dependent" size="20" maxlength="255">
                 &nbsp;<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());
 }
Ejemplo n.º 4
0
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();
}
 /**
  * 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;
 }
Ejemplo n.º 6
0
 $title_arr[] = 'Message: ' . $msg_id;
 echo html_build_list_table_top($title_arr);
 $poster = UserManager::instance()->getUserByUserName(db_result($result, 0, "user_name"));
 echo "<TR><TD class=\"threadmsg\">\n";
 echo $Language->getText('forum_message', 'by') . ": " . UserHelper::instance()->getLinkOnUser($poster) . "<BR>";
 echo $Language->getText('forum_message', 'date') . ": " . format_date($GLOBALS['Language']->getText('system', 'datefmt'), db_result($result, 0, "date")) . "<BR>";
 echo $Language->getText('forum_message', 'subject') . ": " . db_result($result, 0, "subject") . "<P>";
 echo util_make_links(nl2br(db_result($result, 0, 'body')), $group_id);
 echo "</TD></TR>";
 $crossref_fact = new CrossReferenceFactory($msg_id, ReferenceManager::REFERENCE_NATURE_FORUMMESSAGE, $group_id);
 $crossref_fact->fetchDatas();
 if ($crossref_fact->getNbReferences() > 0) {
     echo '<tr>';
     echo ' <td class="forum_reference_separator">';
     echo '  <b> ' . $Language->getText('cross_ref_fact_include', 'references') . '</b>';
     echo $crossref_fact->getHTMLDisplayCrossRefs();
     echo ' </td>';
     echo '</tr>';
 }
 echo "</TABLE>";
 if ($pv == 0) {
     /*
     	Show entire thread
     */
     echo '<BR>&nbsp;<P><H3>' . $Language->getText('forum_message', 'thread_view') . '</H3>';
     //highlight the current message in the thread list
     $current_message = $msg_id;
     echo show_thread(db_result($result, 0, 'thread_id'));
     /*
     	Show post followup form
     */