Add support for page credits.
This commit is contained in:
parent
3adf419b35
commit
b14b6aa693
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,2 +1,5 @@
|
|||
uploads
|
||||
attachments/
|
||||
documents/
|
||||
history/
|
||||
requests/
|
||||
*.sql
|
||||
|
|
|
@ -50,7 +50,9 @@ Markdown document and it can be at any point.
|
|||
- `@csgen.displayDate = "true";`
|
||||
- `@csgen.displaySource = "true";`
|
||||
- `@csgen.displayLicense = "true";`
|
||||
- `@csgen.displayAuthors = "true"`
|
||||
- `@csgen.enableComments = "true";`
|
||||
- `@csgen.addAuthor = "one author here";`
|
||||
- `@csgen.span<STYLE, TEXT>("color: #0000ff;", "thisIsRedText");`
|
||||
- `@csgen.span<STYLE, HTML>("color: #0000ff;", "<p>thisIsARedHTMLTag</p>");`
|
||||
- `@csgen.inline<HTML>("<small>myHtmlHere</small>");`
|
||||
|
|
226
core.php
226
core.php
|
@ -12,10 +12,12 @@ class parsedMarkdown {
|
|||
public $license = '';
|
||||
public $date = '';
|
||||
public $data = '';
|
||||
public $authors = array();
|
||||
public $allowComments = false;
|
||||
public $displayTitle = false;
|
||||
public $displayDate = false;
|
||||
public $displaySource = true;
|
||||
public $displayAuthors = false;
|
||||
public $displayLicense = false;
|
||||
}
|
||||
|
||||
|
@ -155,10 +157,12 @@ function convertMarkdownToHTML($contents) {
|
|||
'/.*@csgen\.favicon.*=.*"(.*)(");/',
|
||||
'/.*@csgen\.license.*=.*"(.*)(");/',
|
||||
'/.*@csgen\.date.*=.*"(.*)(");/',
|
||||
'/.*@csgen\.addAuthor.*=.*"(.*)(");/',
|
||||
'/.*@csgen\.allowComments.*=.*"(.*)(");/',
|
||||
'/.*@csgen\.displayTitle.*=.*"(.*)(");/',
|
||||
'/.*@csgen\.displayDate.*=.*"(.*)(");/',
|
||||
'/.*@csgen\.displaySource.*=.*"(.*)(");/',
|
||||
'/.*@csgen\.displayAuthors.*=.*"(.*)(");/',
|
||||
'/.*@csgen\.displayLicense.*=.*"(.*)(");/',
|
||||
'/.*@csgen\.span.*<STYLE.*,.*TEXT>\(.*"(.*)".*, "(.*)"\);/',
|
||||
'/.*@csgen\.span.*<STYLE.*,.*HTML>\(.*"(.*)".*, "(.*)"\);/',
|
||||
|
@ -176,117 +180,129 @@ function convertMarkdownToHTML($contents) {
|
|||
|
||||
$out = $parser->transform($contents);
|
||||
|
||||
foreach ($specialSyntax as $pattern) {
|
||||
$matches = array();
|
||||
while (preg_match('/.*@csgen.*;/', $out)) {
|
||||
foreach ($specialSyntax as $pattern) {
|
||||
$matches = array();
|
||||
|
||||
if (preg_match($pattern, $out, $matches)) {
|
||||
switch ($pattern) {
|
||||
case '/.*@csgen\.title.*=.*"(.*)(");/':
|
||||
$ret->title = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
if (preg_match($pattern, $out, $matches)) {
|
||||
switch ($pattern) {
|
||||
case '/.*@csgen\.title.*=.*"(.*)(");/':
|
||||
$ret->title = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
|
||||
break;
|
||||
case '/.*@csgen\.description.*=.*"(.*)(");/':
|
||||
$ret->description = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
break;
|
||||
case '/.*@csgen\.description.*=.*"(.*)(");/':
|
||||
$ret->description = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
|
||||
break;
|
||||
case '/.*@csgen\.favicon.*=.*"(.*)(");/':
|
||||
$ret->favicon = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
break;
|
||||
case '/.*@csgen\.favicon.*=.*"(.*)(");/':
|
||||
$ret->favicon = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
|
||||
break;
|
||||
case '/.*@csgen\.license.*=.*"(.*)(");/':
|
||||
$ret->license = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
break;
|
||||
case '/.*@csgen\.license.*=.*"(.*)(");/':
|
||||
$ret->license = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
|
||||
break;
|
||||
case '/.*@csgen\.date.*=.*"(.*)(");/':
|
||||
$ret->date = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
break;
|
||||
case '/.*@csgen\.date.*=.*"(.*)(");/':
|
||||
$ret->date = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
|
||||
break;
|
||||
case '/.*@csgen\.allowComments.*=.*"(.*)(");/':
|
||||
$ret->allowComments = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
break;
|
||||
case '/.*@csgen\.allowComments.*=.*"(.*)(");/':
|
||||
$ret->allowComments = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
|
||||
break;
|
||||
case '/.*@csgen\.displayTitle.*=.*"(.*)(");/':
|
||||
$ret->displayTitle = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
break;
|
||||
case '/.*@csgen\.displayTitle.*=.*"(.*)(");/':
|
||||
$ret->displayTitle = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
|
||||
break;
|
||||
case '/.*@csgen\.displayDate.*=.*"(.*)(");/':
|
||||
$ret->displayDate = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
break;
|
||||
case '/.*@csgen\.displayDate.*=.*"(.*)(");/':
|
||||
$ret->displayDate = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
|
||||
break;
|
||||
case '/.*@csgen\.displaySource.*=.*"(.*)(");/':
|
||||
$ret->displaySource = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
break;
|
||||
case '/.*@csgen\.displaySource.*=.*"(.*)(");/':
|
||||
$ret->displaySource = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
|
||||
break;
|
||||
case '/.*@csgen\.displayLicense.*=.*"(.*)(");/':
|
||||
$ret->displayLicense = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
break;
|
||||
case '/.*@csgen\.displayAuthors.*=.*"(.*)(");/':
|
||||
$ret->displayAuthors = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
|
||||
break;
|
||||
case '/.*@csgen\.span.*<STYLE.*,.*TEXT>\(.*"(.*)".*, "(.*)"\);/':
|
||||
$cssCode = htmlspecialchars_decode($matches[1]);
|
||||
$out = str_replace($matches[0], "<span style=\"$cssCode\">$matches[2]</span>", $out);
|
||||
break;
|
||||
case '/.*@csgen\.span.*<STYLE.*,.*HTML>\(.*"(.*)".*, "(.*)"\);/':
|
||||
$cssCode = htmlspecialchars_decode($matches[1]);
|
||||
$htmlCode = htmlspecialchars_decode($matches[2]);
|
||||
$out = str_replace($matches[0], "<span style=\"$cssCode\">$htmlCode</span>", $out);
|
||||
break;
|
||||
case '/.*@csgen\.div.*<START.*,.*NAME>\(.*"(.*)"\);/':
|
||||
$out = str_replace($matches[0], "<div class=\"$matches[1]\">", $out);
|
||||
break;
|
||||
case '/.*@csgen\.div.*<END.*,.*NAME>\(.*"(.*)"\);/':
|
||||
$out = str_replace($matches[0], "</div>", $out);
|
||||
break;
|
||||
case '/.*@csgen\.div.*<STYLE.*,.*NAME>\(.*"(.*)".*, "(.*)"\);/':
|
||||
$cssCode = htmlspecialchars_decode($matches[1]);
|
||||
$out = str_replace($matches[0], "<style>\n.$matches[2] {\n\t$cssCode\n}\n</style>\n<div class=\"$matches[2]\">", $out);
|
||||
break;
|
||||
case '/.*@csgen\.inline.*<HTML>\(.*"(.*)"\);/':
|
||||
$htmlCode = htmlspecialchars_decode($matches[1]);
|
||||
$out = str_replace($matches[0], "$htmlCode", $out);
|
||||
break;
|
||||
case '/.*@csgen\.inline.*<CSS>\(.*"(.*)"\);/':
|
||||
$cssCode = htmlspecialchars_decode($matches[1]);
|
||||
$out = str_replace($matches[0], "<style>$cssCode</style>", $out);
|
||||
break;
|
||||
case '/.*@csgen\.inline.*<JAVASCRIPT>\(.*"(.*)"\);/':
|
||||
$javascriptCode = htmlspecialchars_decode($matches[1]);
|
||||
$out = str_replace($matches[0], "<script>$javascriptCode</script>", $out);
|
||||
break;
|
||||
case '/.*@csgen\.image.*<SIZE.*,.*PATH>\(.*"(.*)".*, "(.*)"\);/':
|
||||
$imgres = array();
|
||||
if (preg_match('/([0-9]*)x([0-9]*)/', $matches[1], $imgres)) {
|
||||
$out = str_replace($matches[0], "<img width=\"$imgres[1]\" height=\"$imgres[2]\" src=\"$matches[2]\">", $out);
|
||||
}
|
||||
break;
|
||||
case '/.*@csgen\.displayLicense.*=.*"(.*)(");/':
|
||||
$ret->displayLicense = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
|
||||
break;
|
||||
case '/.*@csgen\.include.*<HTML>\(.*"(.*)"\);/':
|
||||
if (file_exists($matches[1])) {
|
||||
$out = str_replace($matches[0], file_get_contents($matches[1]), $out);
|
||||
}
|
||||
break;
|
||||
case '/.*@csgen\.addAuthor.*=.*"(.*)(");/':
|
||||
$ret->authors[] = $matches[1];
|
||||
$out = str_replace($matches[0], '', $out);
|
||||
|
||||
break;
|
||||
case '/.*@csgen\.include.*<CSS>\(.*"(.*)"\);/':
|
||||
if (file_exists($matches[1])) {
|
||||
$out = str_replace($matches[0], "<link rel=\"stylesheet\" href=\"$matches[1]\">", $out);
|
||||
}
|
||||
break;
|
||||
case '/.*@csgen\.span.*<STYLE.*,.*TEXT>\(.*"(.*)".*, "(.*)"\);/':
|
||||
$cssCode = htmlspecialchars_decode($matches[1]);
|
||||
$out = str_replace($matches[0], "<span style=\"$cssCode\">$matches[2]</span>", $out);
|
||||
break;
|
||||
case '/.*@csgen\.span.*<STYLE.*,.*HTML>\(.*"(.*)".*, "(.*)"\);/':
|
||||
$cssCode = htmlspecialchars_decode($matches[1]);
|
||||
$htmlCode = htmlspecialchars_decode($matches[2]);
|
||||
$out = str_replace($matches[0], "<span style=\"$cssCode\">$htmlCode</span>", $out);
|
||||
break;
|
||||
case '/.*@csgen\.div.*<START.*,.*NAME>\(.*"(.*)"\);/':
|
||||
$out = str_replace($matches[0], "<div class=\"$matches[1]\">", $out);
|
||||
break;
|
||||
case '/.*@csgen\.div.*<END.*,.*NAME>\(.*"(.*)"\);/':
|
||||
$out = str_replace($matches[0], "</div>", $out);
|
||||
break;
|
||||
case '/.*@csgen\.div.*<STYLE.*,.*NAME>\(.*"(.*)".*, "(.*)"\);/':
|
||||
$cssCode = htmlspecialchars_decode($matches[1]);
|
||||
$out = str_replace($matches[0], "<style>\n.$matches[2] {\n\t$cssCode\n}\n</style>\n<div class=\"$matches[2]\">", $out);
|
||||
break;
|
||||
case '/.*@csgen\.inline.*<HTML>\(.*"(.*)"\);/':
|
||||
$htmlCode = htmlspecialchars_decode($matches[1]);
|
||||
$out = str_replace($matches[0], "$htmlCode", $out);
|
||||
break;
|
||||
case '/.*@csgen\.inline.*<CSS>\(.*"(.*)"\);/':
|
||||
$cssCode = htmlspecialchars_decode($matches[1]);
|
||||
$out = str_replace($matches[0], "<style>$cssCode</style>", $out);
|
||||
break;
|
||||
case '/.*@csgen\.inline.*<JAVASCRIPT>\(.*"(.*)"\);/':
|
||||
$javascriptCode = htmlspecialchars_decode($matches[1]);
|
||||
$out = str_replace($matches[0], "<script>$javascriptCode</script>", $out);
|
||||
break;
|
||||
case '/.*@csgen\.image.*<SIZE.*,.*PATH>\(.*"(.*)".*, "(.*)"\);/':
|
||||
$imgres = array();
|
||||
if (preg_match('/([0-9]*)x([0-9]*)/', $matches[1], $imgres)) {
|
||||
$out = str_replace($matches[0], "<img width=\"$imgres[1]\" height=\"$imgres[2]\" src=\"$matches[2]\">", $out);
|
||||
}
|
||||
|
||||
break;
|
||||
case '/.*@csgen\.include.*<JAVASCRIPT>\(.*"(.*)"\);/':
|
||||
if (file_exists($matches[1])) {
|
||||
$out = str_replace($matches[0], "<script src=\"$matches[1]\"></script>", $out);
|
||||
}
|
||||
break;
|
||||
case '/.*@csgen\.include.*<HTML>\(.*"(.*)"\);/':
|
||||
if (file_exists($matches[1])) {
|
||||
$out = str_replace($matches[0], file_get_contents($matches[1]), $out);
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
case '/.*@csgen\.include.*<CSS>\(.*"(.*)"\);/':
|
||||
if (file_exists($matches[1])) {
|
||||
$out = str_replace($matches[0], "<link rel=\"stylesheet\" href=\"$matches[1]\">", $out);
|
||||
}
|
||||
|
||||
break;
|
||||
case '/.*@csgen\.include.*<JAVASCRIPT>\(.*"(.*)"\);/':
|
||||
if (file_exists($matches[1])) {
|
||||
$out = str_replace($matches[0], "<script src=\"$matches[1]\"></script>", $out);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -466,10 +482,26 @@ function printHeader($html, $printpage) {
|
|||
$html .= "\t\t\t\t<a id=\"modify\" href=\"/edit-page.php?id=$pid\">Request changes</a>\n";
|
||||
}
|
||||
|
||||
if ($ret->displayLicense == "true") {
|
||||
if ($ret->displayLicense == "true" && $License != '') {
|
||||
$html .= "\t\t\t\tThis page is licensed under the $License license.";
|
||||
}
|
||||
|
||||
if ($ret->displayAuthors == "true" && $ret->authors) {
|
||||
$html .= "\t\t\t\t<h2 id=\"authors\">Authors</h2>\n";
|
||||
|
||||
$html .= "\t\t\t\t<p>";
|
||||
|
||||
foreach ($ret->authors as $i => $it) {
|
||||
$html .= "$it";
|
||||
|
||||
if (count($ret->authors) != $i + 1) {
|
||||
$html .= ", ";
|
||||
}
|
||||
}
|
||||
|
||||
$html .= "\t\t\t\t</p>\n";
|
||||
}
|
||||
|
||||
if ($ret->allowComments == "true") {
|
||||
$html = printCommentField($html, $line['id'], $pid);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue