Browse Source

Cleanup

pull/674/head
danpros 1 year ago
parent
commit
1b4051f711
2 changed files with 17 additions and 35 deletions
  1. +7
    -14
      system/admin/admin.php
  2. +10
    -21
      system/includes/functions.php

+ 7
- 14
system/admin/admin.php View File

@ -119,7 +119,6 @@ function remove_accent($str)
// Add content // Add content
function add_content($title, $tag, $url, $content, $user, $draft, $category, $type, $description = null, $media = null, $dateTime = null) function add_content($title, $tag, $url, $content, $user, $draft, $category, $type, $description = null, $media = null, $dateTime = null)
{ {
$tag = explode(',', preg_replace("/\s*,\s*/", ",", rtrim($tag, ','))); $tag = explode(',', preg_replace("/\s*,\s*/", ",", rtrim($tag, ',')));
$tag = array_filter(array_unique($tag)); $tag = array_filter(array_unique($tag));
$tagslang = "content/data/tags.lang"; $tagslang = "content/data/tags.lang";
@ -257,7 +256,6 @@ function add_content($title, $tag, $url, $content, $user, $draft, $category, $ty
// Edit content // Edit content
function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, $type, $destination = null, $description = null, $date = null, $media = null) function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, $type, $destination = null, $description = null, $date = null, $media = null)
{ {
$tag = explode(',', preg_replace("/\s*,\s*/", ",", rtrim($tag, ','))); $tag = explode(',', preg_replace("/\s*,\s*/", ",", rtrim($tag, ',')));
$tag = array_filter(array_unique($tag)); $tag = array_filter(array_unique($tag));
$tagslang = "content/data/tags.lang"; $tagslang = "content/data/tags.lang";
@ -489,7 +487,6 @@ function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publ
// Add static page // Add static page
function add_page($title, $url, $content, $draft, $description = null) function add_page($title, $url, $content, $draft, $description = null)
{ {
$post_title = safe_html($title); $post_title = safe_html($title);
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
$description = safe_html($description); $description = safe_html($description);
@ -549,7 +546,6 @@ function add_page($title, $url, $content, $draft, $description = null)
// Add static sub page // Add static sub page
function add_sub_page($title, $url, $content, $static, $draft, $description = null) function add_sub_page($title, $url, $content, $static, $draft, $description = null)
{ {
$post = find_page($static); $post = find_page($static);
$static = pathinfo($post['current']->md, PATHINFO_FILENAME); $static = pathinfo($post['current']->md, PATHINFO_FILENAME);
$post_title = safe_html($title); $post_title = safe_html($title);
@ -1130,7 +1126,6 @@ function find_scheduled($year, $month, $name)
// Return scheduled list // Return scheduled list
function get_scheduled($profile, $page, $perpage) function get_scheduled($profile, $page, $perpage)
{ {
$user = $_SESSION[site_url()]['user']; $user = $_SESSION[site_url()]['user'];
$role = user('role', $user); $role = user('role', $user);
$posts = get_scheduled_posts(); $posts = get_scheduled_posts();
@ -1465,7 +1460,8 @@ function valueMaker($value)
return (string)$value; return (string)$value;
} }
function replace_key($arr, $oldkey, $newkey) {
function replace_key($arr, $oldkey, $newkey)
{
if(array_key_exists($oldkey, $arr)) { if(array_key_exists($oldkey, $arr)) {
$keys = array_keys($arr); $keys = array_keys($arr);
$keys[array_search($oldkey, $keys)] = $newkey; $keys[array_search($oldkey, $keys)] = $newkey;
@ -1477,7 +1473,6 @@ function replace_key($arr, $oldkey, $newkey) {
// rename category folder // rename category folder
function rename_category_folder($new_name, $old_file) function rename_category_folder($new_name, $old_file)
{ {
$old_name = str_replace('.md', '', basename($old_file)); $old_name = str_replace('.md', '', basename($old_file));
$dir = get_category_folder(); $dir = get_category_folder();
foreach ($dir as $index => $v) { foreach ($dir as $index => $v) {
@ -1488,13 +1483,11 @@ function rename_category_folder($new_name, $old_file)
rename($old_folder, $new_folder); rename($old_folder, $new_folder);
} }
} }
} }
// reorder the static page // reorder the static page
function reorder_pages($pages = null) function reorder_pages($pages = null)
{ {
$i = 1; $i = 1;
$arr = array(); $arr = array();
$dir = 'content/static/'; $dir = 'content/static/';
@ -1504,7 +1497,7 @@ function reorder_pages($pages = null)
$arr = explode('.' , $fn); $arr = explode('.' , $fn);
if (isset($arr[1])) { if (isset($arr[1])) {
rename ($dir . $p, $dir . $num . '.' . $arr[1] . '.md'); rename ($dir . $p, $dir . $num . '.' . $arr[1] . '.md');
if (is_dir($dir . $fn)) { if (is_dir($dir . $fn)) {
rename($dir . $fn, $dir . $num . '.' . $arr[1]); rename($dir . $fn, $dir . $num . '.' . $arr[1]);
} }
@ -1515,13 +1508,13 @@ function reorder_pages($pages = null)
if (is_dir($dir . $fn)) { if (is_dir($dir . $fn)) {
rename($dir . $fn, $dir . $num . '.' . $fn); rename($dir . $fn, $dir . $num . '.' . $fn);
} }
} }
$i++; $i++;
} }
rebuilt_cache(); rebuilt_cache();
} }
// reorder the subpage // reorder the subpage
@ -1541,7 +1534,7 @@ function reorder_subpages($subpages = null)
rename($dir . $sp, $dn . $num . '.' . $fn . '.md'); rename($dir . $sp, $dn . $num . '.' . $fn . '.md');
} }
$i++;
$i++;
} }


+ 10
- 21
system/includes/functions.php View File

@ -931,7 +931,7 @@ function default_category($category = null)
$tmp = array(); $tmp = array();
$desc = new stdClass; $desc = new stdClass;
if (is_null($category)) {
if (is_null($category) || $category == 'uncategorized') {
$desc->title = i18n("Uncategorized"); $desc->title = i18n("Uncategorized");
$desc->url = site_url() . 'category/uncategorized'; $desc->url = site_url() . 'category/uncategorized';
$desc->slug = 'uncategorized'; $desc->slug = 'uncategorized';
@ -940,16 +940,7 @@ function default_category($category = null)
$desc->description = i18n('Uncategorized_comment'); $desc->description = i18n('Uncategorized_comment');
$desc->file = ''; $desc->file = '';
$desc->count = get_categorycount($desc->slug); $desc->count = get_categorycount($desc->slug);
} elseif ($category == 'uncategorized') {
$desc->title = i18n("Uncategorized");
$desc->url = site_url() . 'category/uncategorized';
$desc->slug = 'uncategorized';
$desc->body = '<p>' . i18n('Uncategorized_comment') . '</p>';
$desc->md = 'uncategorized.md';
$desc->description = i18n('Uncategorized_comment');
$desc->file = '';
$desc->count = get_categorycount($desc->slug);
} else {
} else{
$desc->title = $category; $desc->title = $category;
$desc->url = site_url() . 'category/' . $category; $desc->url = site_url() . 'category/' . $category;
$desc->slug = $category; $desc->slug = $category;
@ -964,8 +955,8 @@ function default_category($category = null)
} }
// Return category list // Return category list
function category_list($custom = null) {
function category_list($custom = null)
{
$dir = "cache/widget"; $dir = "cache/widget";
$filename = "cache/widget/category.list.cache"; $filename = "cache/widget/category.list.cache";
$tmp = array(); $tmp = array();
@ -1240,7 +1231,6 @@ function get_keyword($keyword, $page, $perpage)
// Get related posts base on post category. // Get related posts base on post category.
function get_related($tag, $custom = null, $count = null) function get_related($tag, $custom = null, $count = null)
{ {
if (empty($count)) { if (empty($count)) {
$count = config('related.count'); $count = config('related.count');
if (empty($count)) { if (empty($count)) {
@ -1516,7 +1506,6 @@ function recent_type($type, $custom = null, $count = null)
// Return popular posts lists // Return popular posts lists
function popular_posts($custom = null, $count = null) function popular_posts($custom = null, $count = null)
{ {
static $_views = array(); static $_views = array();
$tmp = array(); $tmp = array();
@ -1605,7 +1594,6 @@ function popular_posts($custom = null, $count = null)
// Return an archive list, categorized by year and month. // Return an archive list, categorized by year and month.
function archive_list($custom = null) function archive_list($custom = null)
{ {
$dir = "cache/widget"; $dir = "cache/widget";
$filename = "cache/widget/archive.cache"; $filename = "cache/widget/archive.cache";
$ar = array(); $ar = array();
@ -1712,7 +1700,6 @@ EOF;
// Return tag cloud. // Return tag cloud.
function tag_cloud($custom = null) function tag_cloud($custom = null)
{ {
$dir = "cache/widget"; $dir = "cache/widget";
$filename = "cache/widget/tags.cache"; $filename = "cache/widget/tags.cache";
$tg = array(); $tg = array();
@ -2043,7 +2030,6 @@ function get_description($string, $char = null)
// Get the teaser // Get the teaser
function get_teaser($string, $url = null, $char = null) function get_teaser($string, $url = null, $char = null)
{ {
$teaserType = config('teaser.type'); $teaserType = config('teaser.type');
$more = config('read.more'); $more = config('read.more');
@ -2338,11 +2324,13 @@ EOF;
} }
} }
function slashUrl($url) {
function slashUrl($url)
{
return rtrim($url, '/') . '/'; return rtrim($url, '/') . '/';
} }
function parseNodes($nodes, $child = null, $class = null) {
function parseNodes($nodes, $child = null, $class = null)
{
if (empty($child)) { if (empty($child)) {
$ul = '<ul class="nav navbar-nav '.$class.'">'; $ul = '<ul class="nav navbar-nav '.$class.'">';
foreach ($nodes as $node) { foreach ($nodes as $node) {
@ -2368,7 +2356,8 @@ function parseNodes($nodes, $child = null, $class = null) {
} }
} }
function parseNode($node, $child = null) {
function parseNode($node, $child = null)
{
$req = strtok($_SERVER["REQUEST_URI"],'?'); $req = strtok($_SERVER["REQUEST_URI"],'?');
$url = parse_url(slashUrl($node->slug)); $url = parse_url(slashUrl($node->slug));
$su = parse_url(site_url()); $su = parse_url(site_url());


Loading…
Cancel
Save