function GetFileContent($unitId, &$filename) { // generate the unit's file $unitInfos = GetUnitInfos($unitId); $items = GetItemsInUnit($unitId); if (!is_array($items)) { die($items); } $filename = str_replace(".pas", ".dtx", $unitInfos["Name"]); $unitSummary = $unitInfos["Description"]; $unitDescription = ""; if (!(strpos($unitSummary, "\r\n") === 0)) { $unitDescription = substr($unitSummary, strpos($unitSummary, "\r\n") + 2); $unitSummary = substr($unitSummary, 0, strpos($unitSummary, "\r\n")); } $content = ""; $content .= "##Package: " . $unitInfos["Package"] . "\r\n"; $content .= "##Status: " . $unitInfos["Status"] . "\r\n"; $content .= "----------------------------------------------------------------------------------------------------\r\n"; $content .= "@@" . str_replace(".dtx", ".pas", $unitInfos["Name"]) . "\r\n"; $content .= "Summary\r\n"; $content .= Format($unitSummary); $content .= "Author\r\n"; $content .= Format($unitInfos["Author"]); if ($unitDescription != "") { $content .= "Description\r\n"; $content .= Format($unitDescription); } $content .= "\r\n"; // generate for all other items foreach ($items as $item) { $content .= "----------------------------------------------------------------------------------------------------\r\n"; $content .= "@@" . $item["Name"] . "\r\n"; if ($item["Extras"] != "") { $content .= $item["Extras"] . "\r\n"; } if ($item["JVCLInfo"] != "") { $content .= "JVCLInfo\r\n"; $content .= Format($item["JVCLInfo"]); } if ($item["Summary"] != "") { $content .= "Summary\r\n"; $content .= Format($item["Summary"]); } if ($item["Description"] != "") { $content .= "Description\r\n"; $content .= Format($item["Description"]); } if ($item["Parameters"] != "") { $content .= "Parameters\r\n"; $content .= Format($item["Parameters"]); } if ($item["ReturnValue"] != "") { $content .= "Return value\r\n"; $content .= Format($item["ReturnValue"]); } $seeAlsoString = GetSeeAlsoString($item); if ($seeAlsoString != "") { $content .= "See Also\r\n"; $content .= Format($seeAlsoString); } $content .= "\r\n"; } return $content; }
$tpl->setVariable("UNIT_AUTHOR", str_replace("\r\n", ", ", EncodeString($unitInfos["Author"]))); if ($edit) { // set the cancel block if ($unitInfos["Id"] != "") { $tpl->setCurrentBlock("cancel_unit"); // this marker MUST NOT be called UNIT_ID or the first replacement above will be reversed to "" $tpl->setVariable("CANCEL_UNIT_ID", $unitInfos["Id"]); $tpl->parseCurrentBlock("cancel_unit"); } else { $tpl->setCurrentBlock("cancel_project"); // this marker MUST NOT be called PROJECT_ID or the first replacement above will be reversed to "" $tpl->setVariable("CANCEL_PROJECT_ID", $unitInfos["ProjectId"]); $tpl->parseCurrentBlock("cancel_project"); } } else { $unitItems = GetItemsInUnit($unitInfos["Id"], "ORDER BY Name"); if (count($unitItems) > 0) { foreach ($unitItems as $item) { // Assign data to the line in the item list $tpl->setCurrentBlock("item_list"); $tpl->setVariable("ITEM_ID", $item["Id"]); $name = trim($item["Name"]); if ($pos = strpos($name, "@")) { $name = substr($name, 0, $pos) . "<div style=\"margin-left: 25px; margin-top: -2px;\">@" . substr($name, $pos + 1); $name = str_replace("@", "</div><br><div style=\"margin-left: 25px; margin-top: -8px;\">@", $name); $name .= "</div>"; } $tpl->setVariable("ITEM_NAME", $name); $tpl->setVariable("ITEM_SUMMARY", EncodeString(GetSummaryFromItem($item))); $tpl->parseCurrentBlock("item_list"); }