Example #1
0
$tpl->setVariable("UNIT_NAME", str_replace(".dtx", ".pas", $unitInfos["Name"]));
$tpl->setVariable("UNIT_ID", $unitInfos["Id"]);
if (is_numeric($itemId)) {
    SetItemImage($tpl, $itemInfos["Name"], GetProjectIdForItem($itemId));
    $tpl->setVariable("ITEM_NAME", $itemInfos["Name"]);
    $tpl->setVariable("ITEM_ID", $itemId);
    $baseclass = trim(substr($itemInfos["Name"], 0, strpos($itemInfos["Name"], ".")));
    if ($baseclass == "") {
        $baseclass = $itemInfos["Name"];
    }
}
if (!$edit) {
    // Assign data to the Summary block
    if ($itemInfos["Summary"] != "") {
        $tpl->setCurrentBlock("summary");
        $tpl->setVariable("SUMMARY", EncodeString(FormatEndLines(ProcessExtLinks($itemInfos["Summary"]))));
        $tpl->parseCurrentBlock("summary");
    }
    // Assign data to the Parameters block
    if ($itemInfos["Parameters"] != "") {
        $tpl->setCurrentBlock("parameters");
        $tpl->setVariable("PARAMETERS", FormatEndLines($itemInfos["Parameters"]));
        $tpl->parseCurrentBlock("parameters");
    }
    // Assign data to the Return Value block
    if ($itemInfos["ReturnValue"] != "") {
        $tpl->setCurrentBlock("return_value");
        $tpl->setVariable("RETURN_VALUE", FormatEndLines($itemInfos["ReturnValue"]));
        $tpl->parseCurrentBlock("return_value");
    }
    // Assign data to the Description block
Example #2
0
function FormatDescription($description, $baseclass = "")
{
    $lines = explode("\r\n", $description);
    $inList = false;
    $inCode = false;
    $inTable = false;
    $tableEnd = false;
    $tableStart = false;
    $tableContent = array();
    $result = "";
    foreach ($lines as $line) {
        $line = ProcessLinks($line, $baseclass);
        $line = ProcessExtLinks($line);
        if (!(strpos(strtolower($line), "<code>") === false)) {
            $inCode = true;
        }
        if (!(strpos(strtolower($line), "<table>") === false)) {
            $inTable = true;
            $tableStart = true;
            $tableContent = "";
        }
        if (!(strpos(strtolower($line), "</table>") === false)) {
            $inTable = false;
            $tableEnd = true;
            $result .= "\n" . GenerateTable($tableContent) . "\n";
        }
        if (substr(ltrim($line), 0, 2) == "- ") {
            $line = substr($line, 3);
            if (!$inList) {
                $line = "<ul><li>" . $line . "</li>\n";
            } else {
                $line = "<li>" . $line . "</li>\n";
            }
            $inList = true;
        } else {
            if ($inList) {
                $line = "</ul>\n" . $line;
            }
            $inList = false;
            if ($inCode) {
                $line = EscapeHtmlMarkers($line) . "\n";
            } else {
                if (!$inTable) {
                    $line = $line . "<br>\n";
                }
            }
        }
        // Can't use str_ireplace, it's PHP5 only
        $line = preg_replace("/\\\\<CODE\\\\>/i", "<CODE><PRE>", $line, 1);
        $line = preg_replace("/\\\\<\\/CODE\\\\>/i", "</PRE></CODE>", $line, 1);
        if ($inTable && !$tableStart) {
            $tableContent[] = $line;
        } else {
            if (!$tableEnd && !$tableStart) {
                $result .= UnescapeHtmlMarkers($line);
            }
        }
        if (!(strpos(strtolower($line), "</code>") === false)) {
            $inCode = false;
        }
        $tableEnd = false;
        $tableStart = false;
    }
    return $result;
}