change links on top with link

This commit is contained in:
quenousimporte 2024-03-12 12:12:13 +01:00
parent 7d44dc86d2
commit 1d951c063d
2 changed files with 37 additions and 28 deletions

View File

@ -39,6 +39,35 @@
array_unshift($_SESSION['index'], $dir . '/' . $title); array_unshift($_SESSION['index'], $dir . '/' . $title);
} }
function linksdiv($content)
{
$divcontent = '<div class="grey">';
$links = array();
if (preg_match_all('/\[\[(.*)\]\]/', $content, $links, PREG_SET_ORDER))
{
$divcontent .= '<br><div>Internal links:</div>';
foreach($links as $link)
{
$divcontent .= '<div>
<a href="index.php?open=true&param=' . urlencode($link[1]) . '">' . $link[1] . '</a>
</div>';
}
}
$links = array();
if (preg_match_all('/https:(.*)\b/', $content, $links, PREG_SET_ORDER))
{
$divcontent .= '<br><div>External links:</div>';
foreach($links as $link)
{
$divcontent .= '<div>
<a target="_blank" href="https:' . $link[1] . '">https:' . $link[1] . '</a>
</div>';
}
}
$divcontent .= '</div>';
return $divcontent;
}
$nextpage = 'home'; $nextpage = 'home';
if (isset($_GET['clip']) && $_GET['param']) if (isset($_GET['clip']) && $_GET['param'])
@ -47,7 +76,7 @@
savenote('todo', $content); savenote('todo', $content);
$_GET['param'] = ''; $_GET['param'] = '';
} }
else if (isset($_POST['save']) || isset($_POST['home'])) else if (isset($_POST['save']) || isset($_POST['home']) || isset($_POST['links']))
{ {
$title = $_POST['title']; $title = $_POST['title'];
$content = $_POST['content']; $content = $_POST['content'];
@ -118,30 +147,6 @@
require('note.php'); require('note.php');
$links = array();
if (preg_match_all('/\[\[(.*)\]\]/', $content, $links, PREG_SET_ORDER))
{
echo '<div>Internal links:</div>';
foreach($links as $link)
{
echo '<div>
<a href="index.php?open=true&param=' . urlencode($link[1]) . '">' . $link[1] . '</a>
</div>';
}
echo '<br>';
}
$links = array();
if (preg_match_all('/https:(.*)\b/', $content, $links, PREG_SET_ORDER))
{
echo '<div>External links:</div>';
foreach($links as $link)
{
echo '<div>
<a target="_blank" href="https:' . $link[1] . '">https:' . $link[1] . '</a>
</div>';
}
echo '<br>';
}
} }
else if ($nextpage == 'home') else if ($nextpage == 'home')
{ {

View File

@ -4,11 +4,15 @@
<input type="submit" name="save" value="save" accesskey="s"> <input type="submit" name="save" value="save" accesskey="s">
<input type="submit" name="delete" value="delete" accesskey="d"> <input type="submit" name="delete" value="delete" accesskey="d">
<input type="submit" name="preview" value="preview" accesskey="p"> <input type="submit" name="preview" value="preview" accesskey="p">
<input type="submit" name="links" value="links" accesskey="l">
<span class="grey"><?echo $lines; ?> lines</span> <span class="grey"><?echo $lines; ?> lines</span>
<span class="grey"><?echo $words; ?> words</span> <span class="grey"><?echo $words; ?> words</span>
<span class="grey"><?echo $chars; ?> chars</span> <span class="grey"><?echo $chars; ?> chars</span>
<br> <?php if (isset($_POST['links']))
<input autocomplete="off" class="title" name="title" value="<? echo $title; ?>"> {
echo linksdiv($content);
}?>
<div><input autocomplete="off" class="title" name="title" value="<? echo $title; ?>"></div>
</div> </div>
<div class="editor"> <div class="editor">
<textarea rows="<? echo $rows; ?>" autofocus name="content" spellcheck="false"><? echo $content; ?></textarea> <textarea rows="<? echo $rows; ?>" autofocus name="content" spellcheck="false"><? echo $content; ?></textarea>