Browse Source

Cleanup

pull/674/head
danpros 1 year ago
parent
commit
d0283113a3
3 changed files with 37 additions and 22 deletions
  1. +3
    -0
      system/admin/admin.php
  2. +18
    -0
      system/includes/dispatch.php
  3. +16
    -22
      system/includes/functions.php

+ 3
- 0
system/admin/admin.php View File

@ -1315,6 +1315,8 @@ function find_draft_page($static = null)
$post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file))); $post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file)));
$post->md = $url; $post->md = $url;
$post->slug = $url;
$post->parent = null;
// Get the contents and convert it to HTML // Get the contents and convert it to HTML
$content = file_get_contents($post->file); $content = file_get_contents($post->file);
@ -1374,6 +1376,7 @@ function find_draft_subpage($static = null, $sub_static = null)
$post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file))); $post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file)));
$post->md = $url; $post->md = $url;
$post->slug = $url;
// Get the contents and convert it to HTML // Get the contents and convert it to HTML
$content = file_get_contents($post->file); $content = file_get_contents($post->file);


+ 18
- 0
system/includes/dispatch.php View File

@ -65,6 +65,24 @@ function error($code, $message)
die($message); die($message);
} }
// Set the language
function get_language()
{
$langID = config('language');
$langFile = 'lang/'. $langID . '.ini';
// Settings for the language
if (file_exists($langFile)) {
i18n('source', $langFile);
setlocale(LC_ALL, $langID . '.utf8');
} else {
i18n('source', 'lang/en_US.ini'); // Load the English language file
setlocale(LC_ALL, 'en_US.utf8'); // Change locale to English
}
}
// i18n provides strings in the current language // i18n provides strings in the current language
function i18n($key, $value = null) function i18n($key, $value = null)
{ {


+ 16
- 22
system/includes/functions.php View File

@ -445,6 +445,8 @@ function get_posts($posts, $page = 1, $perpage = 0)
} else { } else {
$post->url = site_url() . date('Y/m', $post->date) . '/' . str_replace('.md', '', $arr[2]); $post->url = site_url() . date('Y/m', $post->date) . '/' . str_replace('.md', '', $arr[2]);
} }
$post->slug = str_replace('.md', '', $arr[2]);
$post->file = $filepath; $post->file = $filepath;
@ -550,6 +552,8 @@ function get_pages($pages, $page = 1, $perpage = 0)
$post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file))); $post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file)));
$post->md = $url; $post->md = $url;
$post->slug = $url;
$post->parent = null;
// Get the contents and convert it to HTML // Get the contents and convert it to HTML
$content = file_get_contents($post->file); $content = file_get_contents($post->file);
@ -603,7 +607,7 @@ function get_subpages($sub_pages, $page = 1, $perpage = 0)
$post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file))); $post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file)));
$post->md = $url; $post->md = $url;
$post->slug = $url;
$post->parent = $static; $post->parent = $static;
// Get the contents and convert it to HTML // Get the contents and convert it to HTML
@ -699,6 +703,8 @@ function find_page($static = null)
$post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file))); $post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file)));
$post->md = $url; $post->md = $url;
$post->slug = $url;
$post->parent = null;
// Get the contents and convert it to HTML // Get the contents and convert it to HTML
$content = file_get_contents($post->file); $content = file_get_contents($post->file);
@ -785,7 +791,7 @@ function find_subpage($static, $sub_static = null)
$post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file))); $post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file)));
$post->md = $url; $post->md = $url;
$post->slug = $url;
$post->parent = $static; $post->parent = $static;
// Get the contents and convert it to HTML // Get the contents and convert it to HTML
@ -1168,6 +1174,7 @@ function get_author($name)
$author->file = $filename; $author->file = $filename;
$author->url = site_url() . 'author/' . $profile; $author->url = site_url() . 'author/' . $profile;
$author->slug = $profile;
// Get the contents and convert it to HTML // Get the contents and convert it to HTML
$content = file_get_contents($author->file); $content = file_get_contents($author->file);
@ -1208,6 +1215,7 @@ function default_profile($name)
$author->body = '<p>' . i18n('Author_Description') . '</p>'; $author->body = '<p>' . i18n('Author_Description') . '</p>';
$author->description = i18n('Author_Description'); $author->description = i18n('Author_Description');
$author->url = site_url(). 'author/' . $name; $author->url = site_url(). 'author/' . $name;
$author->slug = $name;
$author->file = ''; $author->file = '';
return $tmp[] = $author; return $tmp[] = $author;
@ -1889,6 +1897,9 @@ function static_prev($prev)
'body' => $prev->body, 'body' => $prev->body,
'description' => $prev->description, 'description' => $prev->description,
'views' => $prev->views, 'views' => $prev->views,
'md' => $prev->md,
'slug' => $prev->slug,
'parent' => $prev->parent,
'file' => $prev->file, 'file' => $prev->file,
'readTime' => $prev->readTime, 'readTime' => $prev->readTime,
'lastMod' => $prev->lastMod 'lastMod' => $prev->lastMod
@ -1905,6 +1916,9 @@ function static_next($next)
'body' => $next->body, 'body' => $next->body,
'description' => $next->description, 'description' => $next->description,
'views' => $next->views, 'views' => $next->views,
'md' => $next->md,
'slug' => $next->slug,
'parent' => $next->parent,
'file' => $next->file, 'file' => $next->file,
'readTime' => $next->readTime, 'readTime' => $next->readTime,
'lastMod' => $next->lastMod 'lastMod' => $next->lastMod
@ -3168,7 +3182,6 @@ function file_cache($request)
} }
$now = time(); $now = time();
$c = str_replace('/', '#', str_replace('?', '~', rawurldecode($request))); $c = str_replace('/', '#', str_replace('?', '~', rawurldecode($request)));
$cachefile = 'cache/page/' . $c . '.cache'; $cachefile = 'cache/page/' . $c . '.cache';
if (file_exists($cachefile)) { if (file_exists($cachefile)) {
@ -3373,25 +3386,6 @@ function replace_href($string, $tag, $class, $url)
} }
// Set the language
function get_language()
{
$langID = config('language');
$langFile = 'lang/'. $langID . '.ini';
$local = $langID;
// Settings for the language
if (!isset($langID) || config('language') === 'en' || config('language') === 'en_US' || !file_exists($langFile)) {
i18n('source', 'lang/en_US.ini'); // Load the English language file
setlocale(LC_ALL, 'en_US.utf8'); // Change locale to English
} else {
i18n('source', $langFile);
setlocale(LC_ALL, $local . '.utf8');
}
}
// Format the date // Format the date
function format_date($date, $dateFormat = null) function format_date($date, $dateFormat = null)
{ {


Loading…
Cancel
Save