flatpress/admin/panels/entry/admin.entry.cats.php
azett af1aa7759b Revert "Merge branch 'master' of https://github.com/flatpressblog/flatpress"
This reverts commit e9ad11742876f9f78d743a28afd547ee7480c7f9, reversing
changes made to f30fc6204a6bc7643d7952b1df98a3aa7b462dea.
2022-07-02 13:30:56 +02:00

75 lines
1.4 KiB
PHP
Executable File

<?php
/**
* plugin control panel
*
* Type:
* Name:
* Date:
* Purpose:
* Input:
*
* @author NoWhereMan <real_nowhereman at users dot sf dot com>
*
*/
class admin_entry_cats extends AdminPanelAction {
var $events = array('save');
function main() {
if (isset($_GET['do']) && $_GET['do'] == 'clear') {
$ret1 = fs_delete(CONTENT_DIR . 'categories_encoded.dat') &&
$ret2 = fs_delete(CONTENT_DIR . 'categories.txt');
$ret = ($ret1 && $ret2) ? 2 : -2;
$this->smarty->assign('success', $ret);
}
if (file_exists(CONTENT_DIR . 'categories.txt')) {
$cats = io_load_file(CONTENT_DIR . 'categories.txt');
$this->smarty->assign('catdefs', $cats);
}
do_action('update_categories', true);
return 0;
}
function onsave() {
$str = stripslashes( trim( @$_POST['content'] ) ) ;
if ($str) {
//$success = io_write_file(CONTENT_DIR . 'categories.txt', $str);
$success = entry_categories_encode($str);
$ret = 1 ;
if ($success <= 0) {
if ($success == -1) $ret = -3;
elseif ($success == 0) $ret = -1;
} else {
$success = io_write_file(CONTENT_DIR . 'categories.txt', $str) ? -1 : 1;
}
$this->smarty->assign('success', $ret);
} else {
$this->smarty->assign('success', -1 );
}
return PANEL_REDIRECT_CURRENT;
}
}
?>