Commit ec990564 authored by Pablo Rauzy's avatar Pablo Rauzy
Browse files

simplify code

parent 03f1ef19
......@@ -173,7 +173,7 @@ function list_files ($ext) {
// Page rendering function
function render ($file, $mode='edit', $entry_dt='NEW') {
global $db, $config, $settings, $pages, $groups, $entries, $cigala_url;
global $db, $config, $settings, $pages, $groups, $entries;
$page = $pages[$file];
$group = ($mode == 'publish') ? (($page['grp'] > 0) ? $page['grp'] : -1) : $page['grp'];
$groups[-1]['name'] = $settings['title'];
......@@ -220,7 +220,7 @@ function render ($file, $mode='edit', $entry_dt='NEW') {
<menu>
<?php foreach ($menu as $p): ?>
<li<?php if ($p['file'] == $file) { echo ' class="current"'; } ?>>
<a href="<?php echo ($mode != 'publish') ? $cigala_url.'?edit='.$p['file'] : (($p['status'] == 'lnk') ? ((strpos($p['content'], '//') === false) ? $relroot : '').$p['content'] : $relroot.preg_replace('/\/?index\.html$/', '/', $p['file'])); ?>"><?php echo $p['title']; ?></a>
<a href="<?php echo ($mode != 'publish') ? 'cigala.php?edit='.$p['file'] : (($p['status'] == 'lnk') ? ((strpos($p['content'], '//') === false) ? $relroot : '').$p['content'] : $relroot.preg_replace('/\/?index\.html$/', '/', $p['file'])); ?>"><?php echo $p['title']; ?></a>
</li>
<?php endforeach; ?>
</menu>
......@@ -228,7 +228,7 @@ function render ($file, $mode='edit', $entry_dt='NEW') {
<?php if ($mode == 'edit' && $page['status'] == 'lnk'): ?>
<div id="main">
<h2>Edit link: <?php echo $page['title']; ?></h2>
<form method="POST" id="page_form" action="<?php echo $cigala_url; ?>?save=<?php echo $file; ?>">
<form method="POST" id="page_form" action="cigala.php?save=<?php echo $file; ?>">
<p>
<label for="page_content">Link target :</label>
<input type="text" name="page_content" id="page_content" value="<?php echo $page['content']; ?>" />
......@@ -245,7 +245,7 @@ function render ($file, $mode='edit', $entry_dt='NEW') {
</optgroup>
</select>
</p>
<p><span>&nbsp;</span><button type="submit">Save</button><a href="<?php echo $cigala_url; ?>#cigala_pages" id="cigala_back">Back</a></p>
<p><span>&nbsp;</span><button type="submit">Save</button><a href="cigala.php#cigala_pages" id="cigala_back">Back</a></p>
</form>
<script>
document.getElementById('link_target').parentNode.style.display = 'table-row';
......@@ -258,7 +258,7 @@ function render ($file, $mode='edit', $entry_dt='NEW') {
<?php elseif ($mode == 'entry'): ?>
<div id="main">
<h2>Edit entry: <?php echo $entry['title']; ?></h2>
<form method="POST" id="entry_form" action="<?php echo $cigala_url; ?>?saveentry=<?php echo $file,':',$entry_dt; ?>">
<form method="POST" id="entry_form" action="cigala.php?saveentry=<?php echo $file,':',$entry_dt; ?>">
<p>
<label for="entry_page">On page :</label>
<select name="entry_page" id="entry_page">
......@@ -281,7 +281,7 @@ function render ($file, $mode='edit', $entry_dt='NEW') {
<label for="entry_content">Content :</label>
<textarea name="entry_content" id="entry_content" width="100%" rows="10"><?php echo $entry['content']; ?></textarea>
</p>
<p><span>&nbsp;</span><button type="submit" id="entry_save">Save</button><a href="<?php echo $cigala_url; ?>?edit=<?php echo $file; ?>">Back (<?php echo $page['title']; ?>)</a></p>
<p><span>&nbsp;</span><button type="submit" id="entry_save">Save</button><a href="cigala.php?edit=<?php echo $file; ?>">Back (<?php echo $page['title']; ?>)</a></p>
</form>
<article id="preview" style="display:none;">
<header>
......@@ -339,7 +339,7 @@ function render ($file, $mode='edit', $entry_dt='NEW') {
<?php echo $page['content']; ?>
</div>
<?php if ($mode == 'edit'): ?>
<form method="POST" id="page_form" action="<?php echo $cigala_url; ?>?save=<?php echo $file; ?>">
<form method="POST" id="page_form" action="cigala.php?save=<?php echo $file; ?>">
<p><textarea name="page_content" id="page_content" width="100%" rows="10" class="page"><?php echo $page['content']; ?></textarea></p>
<p><button type="submit">Save</button></p>
</form>
......@@ -429,7 +429,7 @@ function render ($file, $mode='edit', $entry_dt='NEW') {
});
</script>
<article id="entries_menu">
<a href="<?php echo $cigala_url; ?>?entry=<?php echo $file; ?>:NEW">new entry</a>
<a href="cigala.php?entry=<?php echo $file; ?>:NEW">new entry</a>
</article>
<?php endif; // edit mode ?>
<?php foreach ($page_entries as $entry): ?>
......@@ -437,8 +437,8 @@ function render ($file, $mode='edit', $entry_dt='NEW') {
<header>
<time datetime="<?php echo date('Y-m-d H:i', $entry['datetime']); ?>"><?php echo date('Y-m-d H:i', $entry['datetime']); ?></time>
<?php if ($mode == 'edit'): ?>
<a href="<?php echo $cigala_url; ?>?deleteentry=<?php echo $entry['page'],':',$entry['datetime']; ?>" class="del">×</a>
<a href="<?php echo $cigala_url; ?>?entry=<?php echo $entry['page'],':',$entry['datetime']; ?>">edit</a>
<a href="cigala.php?deleteentry=<?php echo $entry['page'],':',$entry['datetime']; ?>" class="del">×</a>
<a href="cigala.php?entry=<?php echo $entry['page'],':',$entry['datetime']; ?>">edit</a>
<?php endif; ?>
<h2><a href="#<?php echo date('Y-m-d_H-i', $entry['datetime']); ?>"><?php echo $entry['title']; ?></a></h2>
</header>
......@@ -449,7 +449,7 @@ function render ($file, $mode='edit', $entry_dt='NEW') {
<?php endif; // page ?>
<?php if ($mode == 'edit' || $mode == 'entry'): ?>
<div id="banner">
<p>You are editing your website. <a href="<?php echo $cigala_url; ?>#cigala_pages" id="cigala_back">Back</a></p>
<p>You are editing your website. <a href="cigala.php#cigala_pages" id="cigala_back">Back</a></p>
<p id="warning"></p>
</div>
<style type="text/css">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment