Fixed "syntax error, unexpected '['" bug under PHP 5.3, reported here: https://forum.flatpress.org/viewtopic.php?f=2&t=131
This commit is contained in:
parent
a1f5d625ee
commit
50c11928f6
@ -19,18 +19,18 @@ class draft_indexer extends fs_filelister {
|
|||||||
if (is_dir($f) && ctype_digit($file)) {
|
if (is_dir($f) && ctype_digit($file)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fnmatch('entry*' . EXT, $file)) {
|
if (fnmatch('entry*' . EXT, $file)) {
|
||||||
$id = basename($file, EXT);
|
$id = basename($file, EXT);
|
||||||
$arr = draft_parse($id);
|
$arr = draft_parse($id);
|
||||||
|
|
||||||
// $this->add($id, $arr['subject']);
|
// $this->add($id, $arr['subject']);
|
||||||
$this->_list [$id] = $arr ['subject'];
|
$this->_list [$id] = $arr ['subject'];
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function &draft_init() {
|
function &draft_init() {
|
||||||
@ -42,27 +42,27 @@ function &draft_init() {
|
|||||||
|
|
||||||
function draft_getlist() {
|
function draft_getlist() {
|
||||||
static $list = array();
|
static $list = array();
|
||||||
|
|
||||||
if (!$list) {
|
if (!$list) {
|
||||||
$obj = & draft_init();
|
$obj = & draft_init();
|
||||||
$list = $obj->getList();
|
$list = $obj->getList();
|
||||||
krsort($list);
|
krsort($list);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
function draft_parse($id) {
|
function draft_parse($id) {
|
||||||
if ($fname = draft_exists($id)) {
|
if ($fname = draft_exists($id)) {
|
||||||
|
|
||||||
$entry = io_load_file($fname);
|
$entry = io_load_file($fname);
|
||||||
|
|
||||||
$entry = utils_kexplode($entry);
|
$entry = utils_kexplode($entry);
|
||||||
if (!isset($entry ['categories']))
|
if (!isset($entry ['categories']))
|
||||||
$entry ['categories'] = array();
|
$entry ['categories'] = array();
|
||||||
else
|
else
|
||||||
$entry ['categories'] = explode(',', $entry ['categories']);
|
$entry ['categories'] = explode(',', $entry ['categories']);
|
||||||
|
|
||||||
return $entry;
|
return $entry;
|
||||||
}
|
}
|
||||||
return array();
|
return array();
|
||||||
@ -72,38 +72,38 @@ function draft_save(&$entry, $id = null, $update_index = false, $update_date = f
|
|||||||
if (!$id) {
|
if (!$id) {
|
||||||
$id = bdb_idfromtime('entry', $entry ['date']);
|
$id = bdb_idfromtime('entry', $entry ['date']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ed = entry_dir($id);
|
$ed = entry_dir($id);
|
||||||
$dd = draft_dir($id);
|
$dd = draft_dir($id);
|
||||||
|
|
||||||
if (file_exists($ed . EXT)) {
|
if (file_exists($ed . EXT)) {
|
||||||
|
|
||||||
// move collateral files
|
// move collateral files
|
||||||
@rename($ed, $dd);
|
@rename($ed, $dd);
|
||||||
|
|
||||||
if ($update_index) {
|
if ($update_index) {
|
||||||
// delete normal entry
|
// delete normal entry
|
||||||
fs_delete($ed . EXT);
|
fs_delete($ed . EXT);
|
||||||
|
|
||||||
// remove from normal flow
|
// remove from normal flow
|
||||||
$o = & entry_init();
|
$o = & entry_init();
|
||||||
$o->delete($id, null);
|
$o->delete($id, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$new_entry = entry_prepare($entry);
|
$new_entry = entry_prepare($entry);
|
||||||
if ($new_entry ['categories'])
|
if ($new_entry ['categories'])
|
||||||
$new_entry ['categories'] = implode(',', $entry ['categories']);
|
$new_entry ['categories'] = implode(',', $entry ['categories']);
|
||||||
else
|
else
|
||||||
unset($new_entry ['categories']);
|
unset($new_entry ['categories']);
|
||||||
|
|
||||||
$string = utils_kimplode($new_entry);
|
$string = utils_kimplode($new_entry);
|
||||||
|
|
||||||
if (!io_write_file($dd . EXT, $string)) {
|
if (!io_write_file($dd . EXT, $string)) {
|
||||||
return false;
|
return false;
|
||||||
} else
|
} else
|
||||||
return $id;
|
return $id;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,25 +120,25 @@ function draft_exists($id) {
|
|||||||
$dir = draft_dir($id);
|
$dir = draft_dir($id);
|
||||||
if (!$dir)
|
if (!$dir)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$f = $dir . EXT;
|
$f = $dir . EXT;
|
||||||
if (file_exists($f))
|
if (file_exists($f))
|
||||||
return $f;
|
return $f;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function draft_delete($id) {
|
function draft_delete($id) {
|
||||||
$dir = draft_dir($id);
|
$dir = draft_dir($id);
|
||||||
|
|
||||||
$f = $dir . EXT;
|
$f = $dir . EXT;
|
||||||
if (!file_exists($f))
|
if (!file_exists($f))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// $draftdb =& draft_init();
|
// $draftdb =& draft_init();
|
||||||
// $draftdb->delete($id);
|
// $draftdb->delete($id);
|
||||||
fs_delete_recursive($dir);
|
fs_delete_recursive($dir);
|
||||||
|
|
||||||
return fs_delete($f);
|
return fs_delete($f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,14 +154,14 @@ function draft_delete($id) {
|
|||||||
function draft_to_entry($draftid) {
|
function draft_to_entry($draftid) {
|
||||||
$dir = draft_dir($draftid);
|
$dir = draft_dir($draftid);
|
||||||
$dir2 = entry_dir($draftid);
|
$dir2 = entry_dir($draftid);
|
||||||
|
|
||||||
@rename($dir, $dir2);
|
@rename($dir, $dir2);
|
||||||
draft_delete($draftid);
|
draft_delete($draftid);
|
||||||
}
|
}
|
||||||
|
|
||||||
function smarty_block_draftlist($params, $content, &$smarty, &$repeat) {
|
function smarty_block_draftlist($params, $content, &$smarty, &$repeat) {
|
||||||
global $fpdb;
|
global $fpdb;
|
||||||
|
|
||||||
if ($list = draft_getlist()) {
|
if ($list = draft_getlist()) {
|
||||||
$smarty->assign('draft_list', $list);
|
$smarty->assign('draft_list', $list);
|
||||||
return $content;
|
return $content;
|
||||||
@ -169,8 +169,6 @@ function smarty_block_draftlist($params, $content, &$smarty, &$repeat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function smarty_block_draft($params, $content, &$smarty, &$repeat) {
|
function smarty_block_draft($params, $content, &$smarty, &$repeat) {
|
||||||
static $list = array();
|
|
||||||
|
|
||||||
$smarty->assign(array(
|
$smarty->assign(array(
|
||||||
'subject' => '',
|
'subject' => '',
|
||||||
'content' => '',
|
'content' => '',
|
||||||
@ -180,21 +178,21 @@ function smarty_block_draft($params, $content, &$smarty, &$repeat) {
|
|||||||
'id' => ''
|
'id' => ''
|
||||||
));
|
));
|
||||||
$arr = & $smarty->get_template_vars('draft_list');
|
$arr = & $smarty->get_template_vars('draft_list');
|
||||||
|
|
||||||
$id = $subject = null;
|
$id = $subject = null;
|
||||||
if ($arr) {
|
if ($arr) {
|
||||||
$firstElement = utils_array_kshift($arr);
|
$firstElement = utils_array_kshift($arr);
|
||||||
$id = array_keys($firstElement) [0];
|
$id = array_keys($firstElement);
|
||||||
$subject = $firstElement [$id];
|
$subject = $firstElement [$id [0]];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id) {
|
if ($id) {
|
||||||
$smarty->assign('subject', $subject);
|
$smarty->assign('subject', $subject);
|
||||||
$smarty->assign('id', $id);
|
$smarty->assign('id', $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$repeat = (bool) $id;
|
$repeat = (bool) $id;
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user