Getting FlatPress ready for PHP 8: Added a lot of missing checks for undefined variables and array keys in template and PHP files.
This commit is contained in:
parent
9332d78fd1
commit
5a0b7541e7
@ -18,7 +18,7 @@
|
||||
{/foreach}
|
||||
</ul>
|
||||
|
||||
{if $submenu}
|
||||
{if isset($submenu)}
|
||||
<ul id="admin-submenu">
|
||||
{foreach from=$submenu key=subtab item=item}
|
||||
{if $item}
|
||||
@ -34,6 +34,9 @@
|
||||
{/if}
|
||||
|
||||
<div id="admin-content">
|
||||
{if isset($action)}
|
||||
{include file=$admin_resource|default:"admin:$panel/$action"}
|
||||
|
||||
{else}
|
||||
{include file=$admin_resource|default:"admin:$panel"}
|
||||
{/if}
|
||||
</div>
|
||||
|
@ -8,6 +8,9 @@
|
||||
|
||||
|
||||
|
||||
{if !isset($catdefs)}
|
||||
{assign var=catdefs value=""}
|
||||
{/if}
|
||||
{html_form}
|
||||
|
||||
<p>
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
<p>{$panelstrings.descr}</p>
|
||||
|
||||
<form method="get" action="{$smarty.request.PHP_SELF}?p=entry">
|
||||
<form method="get" action="{$smarty.server.PHP_SELF}?p=entry">
|
||||
<p> <input type="hidden" name="p" value="entry" /> </p>
|
||||
<fieldset><legend>{$panelstrings.filter}</legend>
|
||||
<select name="category" class="alignleft">
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
{entry_block}
|
||||
<div id="admin-post-preview">
|
||||
{if $preview}
|
||||
{if isset($preview)}
|
||||
<fieldset id="post-preview"><legend>{$panelstrings.preview}</legend>
|
||||
{include file=preview.tpl}
|
||||
</fieldset>
|
||||
@ -14,7 +14,9 @@
|
||||
|
||||
|
||||
{html_form}
|
||||
|
||||
{if !isset($post)}
|
||||
{assign var=post value=""}
|
||||
{/if}
|
||||
{entry content=$post alwaysshow=true}
|
||||
|
||||
<div id="admin-editor">
|
||||
|
@ -1,6 +1,6 @@
|
||||
<h2>{$panelstrings.head}</h2>
|
||||
{include file=shared:errorlist.tpl}
|
||||
{if $files}
|
||||
{if isset($files)}
|
||||
<p>{$panelstrings.chmod_info}</p>
|
||||
<p><a href="admin.php?p=maintain">{$panelstrings.opt0}</a></p>
|
||||
<ul>
|
||||
@ -9,7 +9,7 @@
|
||||
{/foreach}
|
||||
</ul>
|
||||
<p><a href="admin.php?p=maintain">{$panelstrings.opt0}</a></p>
|
||||
{elseif $phpinfo}
|
||||
{elseif isset($phpinfo)}
|
||||
<p><a href="admin.php?p=maintain">{$panelstrings.opt0}</a></p>
|
||||
{$phpinfo}
|
||||
<p><a href="admin.php?p=maintain">{$panelstrings.opt0}</a></p>
|
||||
|
@ -3,43 +3,48 @@
|
||||
class FPDB_QueryParams {
|
||||
|
||||
var $id = null;
|
||||
|
||||
var $d = null;
|
||||
|
||||
var $m = null;
|
||||
|
||||
var $y = null;
|
||||
|
||||
var $start = 0;
|
||||
|
||||
var $count = -1;
|
||||
|
||||
var $random = 0;
|
||||
|
||||
var $category = 0;
|
||||
|
||||
var $exclude = null;
|
||||
|
||||
var $page = 1;
|
||||
|
||||
var $fullparse = false;
|
||||
|
||||
var $comments = false;
|
||||
|
||||
function __construct($params) {
|
||||
|
||||
if (is_string($params)) {
|
||||
$this->parse_string($params);
|
||||
} elseif (is_array($params)) {
|
||||
$this->validate_array($params);
|
||||
} else {
|
||||
trigger_error("FPDB_QueryParams: parameters were not in a valid form",
|
||||
E_USER_ERROR);
|
||||
trigger_error("FPDB_QueryParams: parameters were not in a valid form", E_USER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pad_date($date) {
|
||||
|
||||
if (is_numeric($date) && strlen($date) <= 2) {
|
||||
return str_pad($date, 2, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
function validate_array($params) {
|
||||
|
||||
global $fp_config;
|
||||
|
||||
if (isset($params ['id'])) {
|
||||
@ -51,23 +56,16 @@
|
||||
$this->count = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isset($params ['fullparse'])) {
|
||||
|
||||
$this->fullparse =
|
||||
is_string($params['fullparse'])?
|
||||
($params['fullparse'] != 'false')
|
||||
:
|
||||
$params['fullparse'];
|
||||
$this->fullparse = is_string($params ['fullparse']) ? ($params ['fullparse'] != 'false') : $params ['fullparse'];
|
||||
|
||||
if ($this->fullparse)
|
||||
$this->comments = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (isset($params ['y'])) {
|
||||
$this->y = $this->pad_date($params ['y']);
|
||||
|
||||
@ -77,9 +75,7 @@
|
||||
if ($this->m && isset($params ['d'])) {
|
||||
$this->d = $this->pad_date($params ['d']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isset($params ['random']) && !$this->id) {
|
||||
@ -103,15 +99,12 @@
|
||||
$this->count = intval($fp_config ['general'] ['maxentries']);
|
||||
}
|
||||
|
||||
|
||||
$this->start = ($this->page - 1) * $this->count;
|
||||
|
||||
|
||||
if (isset($params ['start'])) {
|
||||
$this->start = intval($params ['start']);
|
||||
}
|
||||
|
||||
|
||||
if (isset($params ['category'])) {
|
||||
$this->category = intval($params ['category']);
|
||||
}
|
||||
@ -123,7 +116,6 @@
|
||||
if (isset($params ['exclude'])) {
|
||||
$this->exclude = intval($params ['exclude']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function parse_string($str) {
|
||||
@ -136,27 +128,41 @@
|
||||
class FPDB_Query {
|
||||
|
||||
var $counter = -1;
|
||||
|
||||
var $params = null;
|
||||
|
||||
var $single = false;
|
||||
var $pointer = 0; /* pointer points always to NEXT element */
|
||||
|
||||
var $pointer = 0;
|
||||
|
||||
/* pointer points always to NEXT element */
|
||||
var $processed = false;
|
||||
var $ID = 0; /* query id */
|
||||
|
||||
var $ID = 0;
|
||||
|
||||
/* query id */
|
||||
var $lastentry = array(
|
||||
null,
|
||||
array()
|
||||
);
|
||||
|
||||
var $lastentry = array(null, array());
|
||||
var $localcache = array();
|
||||
|
||||
var $nextid = '';
|
||||
|
||||
var $previd = '';
|
||||
|
||||
var $currentid = '';
|
||||
|
||||
var $main_idx = null;
|
||||
|
||||
var $secondary_idx = null;
|
||||
|
||||
var $walker = null;
|
||||
|
||||
function __construct($params, $ID) {
|
||||
|
||||
global $current_query;
|
||||
|
||||
|
||||
$this->params = new FPDB_QueryParams($params);
|
||||
$this->ID = $ID;
|
||||
|
||||
@ -165,14 +171,11 @@
|
||||
}
|
||||
|
||||
$GLOBALS ['current_query'] = & $this;
|
||||
|
||||
}
|
||||
|
||||
function prepare() {
|
||||
|
||||
global $fpdb;
|
||||
|
||||
|
||||
$fpdb->init();
|
||||
|
||||
$this->main_idx = & $fpdb->get_index($this->params->category);
|
||||
@ -204,9 +207,6 @@
|
||||
|
||||
// force first entry to be loaded: updates count, pointer
|
||||
$this->peekEntry();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function _prepare_single(&$entry_index) {
|
||||
@ -227,11 +227,11 @@
|
||||
$prevkey = entry_timetokey($time + 1);
|
||||
|
||||
$key = entry_idtokey($qp->id);
|
||||
#print_r($key);
|
||||
// print_r($key);
|
||||
|
||||
#$key = entry_idtokey($qp->id);
|
||||
// $key = entry_idtokey($qp->id);
|
||||
if (!($entry_index->has_key($key))) {
|
||||
#trigger_error("FPDB: no entry found for {$qp->id}", E_USER_WARNING);
|
||||
// trigger_error("FPDB: no entry found for {$qp->id}", E_USER_WARNING);
|
||||
$qp->count = 0;
|
||||
return;
|
||||
}
|
||||
@ -240,7 +240,6 @@
|
||||
// i.e. includes the first key $newkey such as $newkey <= $prevkey
|
||||
// also, if $prevkey != $newkey then $prevkey := $newkey
|
||||
|
||||
|
||||
$this->walker = & $entry_index->walker($prevkey, 2, null, null);
|
||||
|
||||
// since we're searching for $prevkey, i.e. a key preceding the target $id
|
||||
@ -267,28 +266,21 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function _prepare_list(&$entry_index) {
|
||||
|
||||
|
||||
$qp = & $this->params;
|
||||
|
||||
$entry_num = 0;
|
||||
|
||||
|
||||
if (!$qp->y) {
|
||||
// searches the whole index
|
||||
|
||||
#$this->local_list = array_keys($entry_index);
|
||||
// $this->local_list = array_keys($entry_index);
|
||||
$firstid = null;
|
||||
|
||||
$index_count = $entry_index->length();
|
||||
$this->walker = & $entry_index->walker($firstid);
|
||||
|
||||
} else {
|
||||
// notice this won't work with cats (for now)
|
||||
|
||||
@ -300,9 +292,7 @@
|
||||
if ($filteredkeys) {
|
||||
$error302var1 = entry_idtokey($filteredkeys [0]);
|
||||
|
||||
$this->walker = $entry_index->walker(
|
||||
$error302var1, true,
|
||||
entry_idtokey($filteredkeys[$index_count-1]), true);
|
||||
$this->walker = $entry_index->walker($error302var1, true, entry_idtokey($filteredkeys [$index_count - 1]), true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,7 +300,6 @@
|
||||
|
||||
// count<0 means 'all'
|
||||
$qp->count = $index_count;
|
||||
|
||||
} elseif (($qp->start + $qp->count) > $index_count) {
|
||||
|
||||
if ($index_count >= $qp->start)
|
||||
@ -318,7 +307,6 @@
|
||||
else
|
||||
$index_count = $qp->start = $qp->count = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// not so great implementation... doesn't work well
|
||||
@ -343,9 +331,7 @@
|
||||
}
|
||||
|
||||
/* reading functions */
|
||||
|
||||
function hasMore() {
|
||||
|
||||
$GLOBALS ['current_query'] = & $this;
|
||||
|
||||
// if system init has not been done (filling pointer variable etc.)
|
||||
@ -356,21 +342,23 @@
|
||||
|
||||
// hasMore() returns false either if pointer exceeded the count
|
||||
// or peekEntry returns false
|
||||
return ((bool) $this->peekEntry()
|
||||
&& $this->pointer < $this->params->start + $this->params->count );
|
||||
return ((bool) $this->peekEntry() && $this->pointer < $this->params->start + $this->params->count);
|
||||
}
|
||||
|
||||
function &peekEntry() {
|
||||
|
||||
global $post;
|
||||
|
||||
$qp = & $this->params;
|
||||
$return = array(false, false);
|
||||
$return = array(
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
if ($this->counter < 0)
|
||||
$this->prepare();
|
||||
|
||||
if ($this->pointer == $this->params->start + $this->params->count) return $return;
|
||||
if ($this->pointer == $this->params->start + $this->params->count)
|
||||
return $return;
|
||||
|
||||
if ($qp->id) {
|
||||
$idx = $this->main_idx;
|
||||
@ -386,34 +374,41 @@
|
||||
|
||||
$post = $entry;
|
||||
|
||||
if (!$entry) return $return;
|
||||
if (!$entry)
|
||||
return $return;
|
||||
} else {
|
||||
$entry = array('subject' => $v);
|
||||
$entry = array(
|
||||
'subject' => $v
|
||||
);
|
||||
$post = $entry;
|
||||
}
|
||||
|
||||
$return = array($this->params->id, $entry);
|
||||
$return = array(
|
||||
$this->params->id,
|
||||
$entry
|
||||
);
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
if (!$this->walker) {
|
||||
$false = array(false, false);
|
||||
$false = array(
|
||||
false,
|
||||
false
|
||||
);
|
||||
return $false;
|
||||
}
|
||||
|
||||
|
||||
// search first eligible post
|
||||
while ($this->walker->valid && $this->pointer < $qp->start) {
|
||||
|
||||
|
||||
$this->previd = $this->currentid;
|
||||
$key = $this->walker->current_key();
|
||||
$id = $this->currentid = entry_keytoid($key);
|
||||
|
||||
if ($this->single)
|
||||
$this->preventry = array('subject' => $this->walker->current_value());
|
||||
|
||||
$this->preventry = array(
|
||||
'subject' => $this->walker->current_value()
|
||||
);
|
||||
|
||||
$this->walker->next();
|
||||
$this->pointer++;
|
||||
@ -423,27 +418,23 @@
|
||||
if ($this->secondary_idx) {
|
||||
|
||||
// skips posts until we find one which is not in the secondary idx
|
||||
while ( $this->walker->valid
|
||||
&& ($key = $this->walker->current_key())
|
||||
&& $this->secondary_idx->has_key($key)) {
|
||||
while ($this->walker->valid && ($key = $this->walker->current_key()) && $this->secondary_idx->has_key($key)) {
|
||||
$this->walker->next();
|
||||
// $qp->count--;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->walker->valid) {
|
||||
$cont = false; return $cont;
|
||||
$cont = false;
|
||||
return $cont;
|
||||
}
|
||||
|
||||
|
||||
// pointer == start
|
||||
|
||||
$prevcurr = $this->currentid;
|
||||
$id = $this->currentid = entry_keytoid($this->walker->current_key());
|
||||
if ($id != $prevcurr) $this->previd = $prevcurr;
|
||||
|
||||
|
||||
if ($id != $prevcurr)
|
||||
$this->previd = $prevcurr;
|
||||
|
||||
if ($qp->fullparse && $this->counter <= 0) {
|
||||
|
||||
@ -451,8 +442,6 @@
|
||||
$cont = array();
|
||||
|
||||
$cont = isset($this->localcache [$id]) ? $this->localcache [$id] : entry_parse($id);
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
// only title
|
||||
@ -460,7 +449,6 @@
|
||||
'subject' => $this->walker->current_value(),
|
||||
'date' => entry_idtotime($id)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
if (!$cont) {
|
||||
@ -476,13 +464,14 @@
|
||||
$post = $cont;
|
||||
$post ['id'] = $id;
|
||||
|
||||
$var = array(&$id, &$cont);
|
||||
$var = array(
|
||||
&$id,
|
||||
&$cont
|
||||
);
|
||||
return $var;
|
||||
|
||||
}
|
||||
|
||||
function &getEntry() {
|
||||
|
||||
if (!$this->hasMore())
|
||||
return false;
|
||||
|
||||
@ -503,8 +492,6 @@
|
||||
return $this->comments->getCount();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function _getOffsetId($offset, $assume_pointer = null) {
|
||||
if (is_int($assume_pointer))
|
||||
$i = $assume_pointer + $offset;
|
||||
@ -517,12 +504,10 @@
|
||||
return $this->currentid = $this->_getOffsetId(0);
|
||||
}
|
||||
|
||||
|
||||
function _fillNextId() {
|
||||
return $this->nextid = $this->_getOffsetId(1);
|
||||
}
|
||||
|
||||
|
||||
function _fillPrevId() {
|
||||
return $this->previd = $this->_getOffsetId(-1);
|
||||
}
|
||||
@ -540,69 +525,75 @@
|
||||
}
|
||||
|
||||
function getNextPage() {
|
||||
|
||||
if ($this->single) {
|
||||
$key = $this->nextkey;
|
||||
if (!$key)
|
||||
return array(null, null);
|
||||
return array(
|
||||
null,
|
||||
null
|
||||
);
|
||||
else {
|
||||
$val = $this->main_idx->getitem($key);
|
||||
return array($val, entry_keytoid($key));
|
||||
return array(
|
||||
$val,
|
||||
entry_keytoid($key)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if ($this->params->page) {
|
||||
#if ($this->_getOffsetId(0, ($this->params->start + $this->params->count)))
|
||||
// if ($this->_getOffsetId(0, ($this->params->start + $this->params->count)))
|
||||
if ($this->walker->valid)
|
||||
return array($GLOBALS['lang']['main']['nextpage'], $this->params->page + 1);
|
||||
|
||||
return array(
|
||||
$GLOBALS ['lang'] ['main'] ['nextpage'],
|
||||
$this->params->page + 1
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getPrevPage() {
|
||||
|
||||
if ($this->single) {
|
||||
$key = $this->prevkey;
|
||||
if (!$key)
|
||||
return array(null, null);
|
||||
return array(
|
||||
null,
|
||||
null
|
||||
);
|
||||
else {
|
||||
$val = $this->main_idx->getitem($key);
|
||||
return array($val, entry_keytoid($key));
|
||||
return array(
|
||||
$val,
|
||||
entry_keytoid($key)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($this->params->page > 1) {
|
||||
return array($GLOBALS['lang']['main']['prevpage'], $this->params->page - 1);
|
||||
return array(
|
||||
$GLOBALS ['lang'] ['main'] ['prevpage'],
|
||||
$this->params->page - 1
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
class FPDB_CommentList {
|
||||
|
||||
var $count = 0;
|
||||
|
||||
var $list = array();
|
||||
|
||||
var $current = '';
|
||||
|
||||
var $entryid = '';
|
||||
|
||||
function __construct($ID, $array) {
|
||||
|
||||
if (is_array($array)) {
|
||||
$this->list = $array;
|
||||
$this->count = count($array);
|
||||
$this->entryid = $ID;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getCount() {
|
||||
@ -610,26 +601,25 @@
|
||||
}
|
||||
|
||||
function hasMore() {
|
||||
|
||||
if ($this->count) {
|
||||
return current($this->list) !== false;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
function &getComment() {
|
||||
|
||||
if (!$this->hasMore())
|
||||
return false;
|
||||
|
||||
$id = array_shift($this->list);
|
||||
|
||||
$comment = comment_parse($this->entryid, $id);
|
||||
$couplet = array(&$id, &$comment);
|
||||
$couplet = array(
|
||||
&$id,
|
||||
&$comment
|
||||
);
|
||||
return $couplet;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -637,23 +627,23 @@
|
||||
class FPDB {
|
||||
|
||||
var $_indexer = array();
|
||||
var $_categories = array();
|
||||
var $queries = array();
|
||||
|
||||
var $_categories = array();
|
||||
|
||||
var $queries = array();
|
||||
|
||||
function __construct() {
|
||||
// constructor
|
||||
}
|
||||
|
||||
function init() {
|
||||
#if (!$this->_indexer) {
|
||||
#$this->_indexer = new entry_indexer();
|
||||
// if (!$this->_indexer) {
|
||||
// $this->_indexer = new entry_indexer();
|
||||
$this->_categories = entry_categories_get();
|
||||
#$obj =& $this->_indexer;
|
||||
#$this->entry_index = $obj->getList();
|
||||
// $obj =& $this->_indexer;
|
||||
// $this->entry_index = $obj->getList();
|
||||
|
||||
|
||||
#}
|
||||
// }
|
||||
}
|
||||
|
||||
function &get_index($cat_id = 0) {
|
||||
@ -664,18 +654,20 @@
|
||||
}
|
||||
|
||||
function reset($queryId = null) {
|
||||
|
||||
switch ($queryId) {
|
||||
case null: $this->_query = array(); break;
|
||||
default: unset($this->_query[$queryId]);
|
||||
case null:
|
||||
$this->_query = array();
|
||||
break;
|
||||
default:
|
||||
unset($this->_query [$queryId]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* function query
|
||||
* @param mixed params
|
||||
*
|
||||
* @param
|
||||
* mixed params
|
||||
* $params may be an associative array or a query string with the following syntax:
|
||||
* 'key:val,key:val,key:val';
|
||||
* example: <code>$params = 'start:0,count:5';<br />
|
||||
@ -715,24 +707,18 @@
|
||||
* set fullparse=true; defaults to false.
|
||||
*
|
||||
*/
|
||||
|
||||
function query($params = array()) {
|
||||
|
||||
static $queryId = -1;
|
||||
$queryId++;
|
||||
|
||||
$this->queries [$queryId] = new FPDB_Query($params, $queryId);
|
||||
|
||||
|
||||
$this->init();
|
||||
|
||||
return $queryId;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function doquery($queryId = 0) {
|
||||
|
||||
if (isset($this->queries [$queryId])) {
|
||||
$q = & $this->queries [$queryId];
|
||||
} else {
|
||||
@ -746,47 +732,41 @@
|
||||
// $this->init();
|
||||
|
||||
/**
|
||||
@todo return true/false
|
||||
*
|
||||
* @todo return true/false
|
||||
*/
|
||||
return $q->prepare($this->entry_index);
|
||||
}
|
||||
|
||||
// "get" functions. todo: move out?
|
||||
|
||||
function &getQuery($queryId = 0) {
|
||||
$o = null;
|
||||
if (isset($this->queries [$queryId]))
|
||||
$o = & $this->queries [$queryId];
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class FPDB_transaction {
|
||||
|
||||
var $_index = null;
|
||||
|
||||
var $_offset = 0;
|
||||
|
||||
var $_nodesize = 30;
|
||||
|
||||
var $_keysize = 12;
|
||||
|
||||
function __construct($id_cat = 0) {
|
||||
$this->_index = INDEX_DIR . 'index-' . $id_cat;
|
||||
|
||||
$this->_tree = caching_SBPT(
|
||||
fopen($this->_cachefile.'.dat', 'r'),
|
||||
fopen($this->_cachefile.'.strings.dat', 'r'),
|
||||
$this->_offset,
|
||||
$this->_chunksize,
|
||||
$this->_keysize
|
||||
);
|
||||
|
||||
$this->_tree = caching_SBPT(fopen($this->_cachefile . '.dat', 'r'), fopen($this->_cachefile . '.strings.dat', 'r'), $this->_offset, $this->_chunksize, $this->_keysize);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// SMARTY FUNCTIONS ----------------------------------------------------
|
||||
|
||||
|
||||
function smarty_block_entries($params, $content, &$smarty, &$repeat) {
|
||||
global $fpdb;
|
||||
|
||||
@ -805,32 +785,26 @@
|
||||
}
|
||||
|
||||
// $show = @$fpdb->doquery();
|
||||
|
||||
} else {
|
||||
|
||||
if (!isset($fpdb->queries [0]->comments) || !$fpdb->queries [0]->comments)
|
||||
$fpdb->reset(0);
|
||||
$show = true;
|
||||
|
||||
}
|
||||
|
||||
$show = true;
|
||||
|
||||
|
||||
|
||||
|
||||
if ($show)
|
||||
return $content;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function smarty_block_entry($params, $content, &$smarty, &$repeat) {
|
||||
global $fpdb;
|
||||
|
||||
// clean old variables
|
||||
|
||||
$smarty->assign(array( 'subject'=>'',
|
||||
$smarty->assign(array(
|
||||
'subject' => '',
|
||||
'content' => '',
|
||||
'categories' => array(),
|
||||
'filed_under' => '',
|
||||
@ -838,10 +812,7 @@
|
||||
'author' => '',
|
||||
'version' => '',
|
||||
'ip-address' => ''
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
));
|
||||
|
||||
if (isset($params ['content']) && is_array($params ['content']) && $params ['content']) {
|
||||
// foreach ($params['entry'] as $k => $val)
|
||||
@ -857,7 +828,6 @@
|
||||
|
||||
if ($repeat = $q->hasMore()) {
|
||||
|
||||
|
||||
$couplet = & $q->getEntry();
|
||||
|
||||
$id = & $couplet [0];
|
||||
@ -867,24 +837,21 @@
|
||||
$entry = theme_entry_filters($entry, $id);
|
||||
}
|
||||
|
||||
|
||||
foreach ($entry as $k => $v)
|
||||
$smarty->assign_by_ref($k, $entry [$k]);
|
||||
|
||||
$smarty->assign_by_ref('id', $id);
|
||||
|
||||
$smarty->assign('entry_commslock', @in_array('commslock',$entry['categories']));
|
||||
if (array_key_exists('categories', $entry)) {
|
||||
$smarty->assign('entry_commslock', in_array('commslock', $entry ['categories']));
|
||||
}
|
||||
|
||||
do_action('entry_block', $id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $content;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function smarty_block_comment($params, $content, &$smarty, &$repeat) {
|
||||
global $fpdb;
|
||||
|
||||
@ -899,9 +866,8 @@
|
||||
'email' => '',
|
||||
'version' => '',
|
||||
'ip-address' => '',
|
||||
'loggedin'=>'',
|
||||
)
|
||||
);
|
||||
'loggedin' => ''
|
||||
));
|
||||
|
||||
$q = & $fpdb->getQuery();
|
||||
|
||||
@ -912,7 +878,6 @@
|
||||
$id = & $couplet [0];
|
||||
$comment = & $couplet [1];
|
||||
|
||||
|
||||
foreach ($comment as $k => $v) {
|
||||
$kk = str_replace('-', '_', $k);
|
||||
$smarty->assign_by_ref($kk, $comment [$k]);
|
||||
@ -923,16 +888,9 @@
|
||||
}
|
||||
|
||||
$smarty->assign('id', $id);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $content;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function smarty_block_comments($params, $content, &$smarty, &$repeat) {
|
||||
@ -942,7 +900,6 @@
|
||||
$show = $q->comments->getCount();
|
||||
$smarty->assign('entryid', $q->comments->entryid);
|
||||
|
||||
|
||||
if ($show) {
|
||||
|
||||
return $content;
|
||||
@ -950,13 +907,14 @@
|
||||
|
||||
$repeat = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function smarty_function_nextpage($params) {
|
||||
|
||||
list ($caption, $link) = get_nextpage_link();
|
||||
$nextPageLink = get_nextpage_link();
|
||||
if (empty($nextPageLink)) {
|
||||
return;
|
||||
}
|
||||
list ($caption, $link) = $nextPageLink;
|
||||
|
||||
if (!$link)
|
||||
return;
|
||||
@ -966,14 +924,15 @@
|
||||
$link = BLOG_BASEURL . 'admin.php' . $qstr;
|
||||
}
|
||||
|
||||
|
||||
return "<div class=\"alignright\"><a href=\"$link\">$caption</a></div>";
|
||||
|
||||
}
|
||||
|
||||
function smarty_function_prevpage($params) {
|
||||
|
||||
list($caption, $link) = get_prevpage_link();
|
||||
$prevPageLink = get_prevpage_link();
|
||||
if (empty($prevPageLink)) {
|
||||
return;
|
||||
}
|
||||
list ($caption, $link) = $prevPageLink;
|
||||
|
||||
if (!$link)
|
||||
return;
|
||||
@ -983,10 +942,7 @@
|
||||
$link = BLOG_BASEURL . 'admin.php' . $qstr;
|
||||
}
|
||||
|
||||
|
||||
return "<div class=\"alignleft\"><a href=\"$link\">$caption</a></div>";
|
||||
|
||||
|
||||
}
|
||||
|
||||
$_FP_SMARTY->register_block('comment', 'smarty_block_comment');
|
||||
|
@ -3,12 +3,10 @@
|
||||
/**
|
||||
* Block-Managing Functions
|
||||
*/
|
||||
|
||||
|
||||
|
||||
class widget_indexer extends fs_filelister {
|
||||
|
||||
var $_varname = 'fp_widgets';
|
||||
|
||||
var $_enabledlist = null;
|
||||
|
||||
function __construct() {
|
||||
@ -21,25 +19,19 @@
|
||||
}
|
||||
|
||||
function getEnableds() {
|
||||
|
||||
if (!file_exists($this->_enabledlist))
|
||||
return;
|
||||
|
||||
include ($this->_enabledlist);
|
||||
|
||||
$this->_list = ${$this->_varname};
|
||||
|
||||
}
|
||||
|
||||
function hasMore($hor) {
|
||||
|
||||
return is_array($this->_list[$hor]) && (current($this->_list[$hor]) !== false);
|
||||
return array_key_exists($hor, $this->_list) && is_array($this->_list [$hor]) && (current($this->_list [$hor]) !== false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function get($hor) {
|
||||
|
||||
global $fp_registered_widgets;
|
||||
|
||||
do {
|
||||
@ -47,8 +39,11 @@
|
||||
|
||||
$id = array_shift($this->_list [$hor]);
|
||||
|
||||
$newid=$id;# @list($newid, $params) = explode(":", $id);
|
||||
if (@$params) $params = explode(',', $params); else $params = array();
|
||||
$newid = $id; // @list($newid, $params) = explode(":", $id);
|
||||
if (@$params)
|
||||
$params = explode(',', $params);
|
||||
else
|
||||
$params = array();
|
||||
// $var = 'plugin_' . $newid . '_widget';
|
||||
$var = $fp_registered_widgets [$newid] ['func'];
|
||||
if (is_callable($var)) {
|
||||
@ -57,26 +52,20 @@
|
||||
$content ['id'] = "widget-$newid";
|
||||
}
|
||||
} /*
|
||||
else $content = array(
|
||||
'subject' => "Sidebar::Error",
|
||||
'content' => "<ul class=\"widget-error\"><li>No $var function found for plugin $newid.
|
||||
Plugin may not have been loaded.
|
||||
Verify whether it is enabled.</li></ul>",
|
||||
);
|
||||
* else $content = array(
|
||||
* 'subject' => "Sidebar::Error",
|
||||
* 'content' => "<ul class=\"widget-error\"><li>No $var function found for plugin $newid.
|
||||
* Plugin may not have been loaded.
|
||||
* Verify whether it is enabled.</li></ul>",
|
||||
* );
|
||||
*/
|
||||
|
||||
} while (!$content && $id);
|
||||
|
||||
return array_change_key_case($content, CASE_LOWER);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function register_widgetset($widgetset) {
|
||||
global $fp_registered_widgetsets;
|
||||
if (!$fp_registered_widgetsets) {
|
||||
@ -85,11 +74,8 @@
|
||||
|
||||
if (!in_array($widgetset, $fp_registered_widgetsets))
|
||||
$fp_registered_widgetsets [] = $widgetset;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function get_registered_widgetsets($widgetset) {
|
||||
global $fp_registered_widgetsets;
|
||||
if (!$fp_registered_widgetsets) {
|
||||
@ -99,10 +85,7 @@
|
||||
return $fp_registered_widgetsets;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function register_widget(
|
||||
$widgetid, // widget id
|
||||
function register_widget($widgetid, // widget id
|
||||
$widgetname, // name to show
|
||||
$widget_func, // function/method to call
|
||||
$num_params = 0, // number of eventually needed parameters
|
||||
@ -110,10 +93,9 @@
|
||||
// 0 means no parameters
|
||||
// each N>0 means *at least* N parameters
|
||||
|
||||
$limit_params_to=array()// indexed array of arrays, containing
|
||||
$limit_params_to = array()) // indexed array of arrays, containing
|
||||
// allowed parameters (not impl.)
|
||||
) {
|
||||
|
||||
{
|
||||
global $fp_registered_widgets;
|
||||
if (!$fp_registered_widgets)
|
||||
$fp_registered_widgets = array();
|
||||
@ -127,32 +109,22 @@
|
||||
// 'needed'=> $params_needed,
|
||||
'params' => $limit_params_to
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function get_registered_widgets($widget = null) {
|
||||
global $fp_registered_widgets;
|
||||
|
||||
if (!$fp_registered_widgets)
|
||||
$fp_registered_widgets = array();
|
||||
|
||||
|
||||
ksort($fp_registered_widgets);
|
||||
|
||||
if ($widget)
|
||||
return isset($fp_registered_widgets[$widget])?
|
||||
$fp_registered_widgets[$widget]
|
||||
:
|
||||
false;
|
||||
return isset($fp_registered_widgets [$widget]) ? $fp_registered_widgets [$widget] : false;
|
||||
|
||||
return $fp_registered_widgets;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function smarty_block_widgets($params, $content, &$smarty, &$repeat) {
|
||||
global $fp_widgets;
|
||||
|
||||
@ -163,12 +135,8 @@
|
||||
}
|
||||
|
||||
return $content;
|
||||
|
||||
}
|
||||
|
||||
|
||||
$smarty->register_block('widgets', 'smarty_block_widgets');
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
@ -7,15 +8,19 @@
|
||||
* Name: list_categories
|
||||
* Purpose: print out the comment form
|
||||
*
|
||||
* @param string after
|
||||
* @param string before
|
||||
* @param
|
||||
* string after
|
||||
* @param
|
||||
* string before
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_function_list_categories($params) // , &$smarty)
|
||||
{
|
||||
$cat_params = array(
|
||||
'ild'=>'<li>','ird'=>"</li>\n",
|
||||
'old'=>"<ul>\n",'ord'=>"</ul>\n",
|
||||
'ild' => '<li>',
|
||||
'ird' => "</li>\n",
|
||||
'old' => "<ul>\n",
|
||||
'ord' => "</ul>\n",
|
||||
'name' => isset($params ['name']) ? $params ['name'] : '',
|
||||
'selected' => array()
|
||||
);
|
||||
@ -23,13 +28,15 @@ function smarty_function_list_categories($params) //, &$smarty)
|
||||
$cat_params = array_merge($cat_params, $params);
|
||||
|
||||
// makese 'selected' an arr
|
||||
$cat_params['selected'] = (array)$params['selected'];
|
||||
$cat_params ['selected'] = array_key_exists('selected', $params) ? (array) $params ['selected'] : array();
|
||||
|
||||
// echo "<pre>" . print_r(entry_categories_get()) . "</pre>";
|
||||
|
||||
if (file_exists(CONTENT_DIR . 'categories.txt')) {
|
||||
$cats = trim(io_load_file(CONTENT_DIR . 'categories.txt'));
|
||||
$stack=array(0);
|
||||
$stack = array(
|
||||
0
|
||||
);
|
||||
$arr = array();
|
||||
|
||||
$line36error = explode("\n", $cats);
|
||||
@ -48,15 +55,9 @@ function smarty_function_list_categories($params) //, &$smarty)
|
||||
// <label><input name="cats[{$catId}]"
|
||||
// {if (bool)array_intersect(array($catId),$categories) }
|
||||
// checked="checked"{/if} type="checkbox" /> {$cat} </label><br />
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function do_print_categories_list(&$lines, &$indentstack, &$result, $params) {
|
||||
|
||||
global $smarty, $fpdb;
|
||||
|
||||
extract($params);
|
||||
@ -72,7 +73,6 @@ function do_print_categories_list(&$lines, &$indentstack, &$result, $params) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
$str = '';
|
||||
$v = reset($lines);
|
||||
$vt = ltrim($v);
|
||||
@ -103,34 +103,33 @@ function do_print_categories_list(&$lines, &$indentstack, &$result, $params) {
|
||||
} else {
|
||||
array_push($result, $ild);
|
||||
|
||||
|
||||
$cat_entry = $params ['selected'];
|
||||
|
||||
if (isset($params ['type']) && ($params ['type'] == 'form' || $params ['type'] == 'check')) {
|
||||
$string = '<label><input name="' . $catname . 'cats[' . $vid . ']" ';
|
||||
|
||||
if ((bool) array_intersect(array($vid), $cat_entry))
|
||||
if ((bool) array_intersect(array(
|
||||
$vid
|
||||
), $cat_entry))
|
||||
$string .= 'checked="checked" ';
|
||||
|
||||
$string .= 'type="checkbox" />';
|
||||
$before = $string;
|
||||
} elseif (isset($params ['type']) && $params ['type'] == 'radio') {
|
||||
$string = '<label><input name="' . $catname . 'cats" type="radio" value="' . $vid . '"';
|
||||
if ((bool) array_intersect(array($vid), $cat_entry))
|
||||
if ((bool) array_intersect(array(
|
||||
$vid
|
||||
), $cat_entry))
|
||||
$string .= 'checked="checked" ';
|
||||
|
||||
$string .= ' />';
|
||||
$before = $string;
|
||||
|
||||
|
||||
} elseif (isset($params ['type']) && $params ['type'] == 'linked') {
|
||||
$before = '<a href="' . get_category_link($vid) . '">';
|
||||
}
|
||||
|
||||
|
||||
array_push($result, $before);
|
||||
|
||||
|
||||
array_push($result, $vt);
|
||||
|
||||
if (isset($params ['type']) && ($params ['type'] == 'form' || $params ['type'] == 'check' || $params ['type'] == 'radio')) {
|
||||
@ -153,5 +152,4 @@ function do_print_categories_list(&$lines, &$indentstack, &$result, $params) {
|
||||
}
|
||||
|
||||
return implode($result);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<div id="errorlist">
|
||||
{if $error}
|
||||
{if isset($error)}
|
||||
<ul class="msgs errors">
|
||||
{foreach from=$error key=field item=msg}
|
||||
<li>
|
||||
@ -13,7 +13,7 @@
|
||||
</ul>
|
||||
{/if}
|
||||
|
||||
{if $warnings}
|
||||
{if isset($warnings)}
|
||||
<ul class="msgs warnings">
|
||||
{foreach from=$warnings key=field item=msg}
|
||||
<li>
|
||||
@ -27,7 +27,7 @@
|
||||
</ul>
|
||||
{/if}
|
||||
|
||||
{if $notifications}
|
||||
{if isset($notifications)}
|
||||
<ul class="msgs notifications">
|
||||
{foreach from=$notifications item=msg}
|
||||
<li>{$msg}</li>
|
||||
|
@ -62,8 +62,8 @@ class plugin_commentcenter {
|
||||
function lock() {
|
||||
global $fp_params, $post, $smarty;
|
||||
$this->loadPolicies();
|
||||
$cats = is_array($post ['categories']) ? $post ['categories'] : array();
|
||||
$behavoir = $this->behavoirFromPolicies($fp_params ['entry'], $cats);
|
||||
$cats = array_key_exists('categories', $post) && is_array($post ['categories']) ? $post ['categories'] : array();
|
||||
$behavoir = array_key_exists('entry', $fp_params) ? $this->behavoirFromPolicies($fp_params ['entry'], $cats) : 1;
|
||||
if ($behavoir == -1 && !user_loggedin()) {
|
||||
$smarty->assign('entry_commslock', true);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user