add('name', PLUGIN_DASHBOARD_TITLE);
$propbag->add('description', PLUGIN_DASHBOARD_DESC);
$propbag->add('requirements', array(
'serendipity' => '1.3',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
$propbag->add('version', '0.6.9');
$propbag->add('author', 'Garvin Hicking');
$propbag->add('stackable', false);
$propbag->add('configuration', array('read_only', 'limit_draft', 'limit_comments', 'limit_comments_pending', 'limit_future', 'sequence', 'update'));
$propbag->add('event_hooks', array(
'backend_frontpage_display' => true,
'css_backend' => true,
)
);
$propbag->add('groups', array('BACKEND_FEATURES'));
}
function introspect_config_item($name, &$propbag) {
switch($name) {
case 'limit_draft':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_DASHBOARD_LIMIT_DRAFT);
$propbag->add('description', '');
$propbag->add('default', '5');
break;
case 'read_only':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_DASHBOARD_READONLY);
$propbag->add('description', PLUGIN_DASHBOARD_READONLY_DESC);
$propbag->add('default', 'false');
break;
case 'update':
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_DASHBOARD_UPDATE);
$propbag->add('description', PLUGIN_DASHBOARD_UPDATE_DESC);
$propbag->add('radio', array(
'value' => array('stable', 'beta', 'none'),
'desc' => array(PLUGIN_DASHBOARD_STABLE, PLUGIN_DASHBOARD_UNSTABLE, PLUGIN_DASHBOARD_NONE)
));
$propbag->add('radio_per_row', '1');
$propbag->add('default', 'stable');
break;
case 'limit_comments':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_DASHBOARD_LIMIT_COMMENTS);
$propbag->add('description', '');
$propbag->add('default', '5');
break;
case 'limit_comments_pending':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_DASHBOARD_LIMIT_COMMENTS_PENDING);
$propbag->add('description', '');
$propbag->add('default', '5');
break;
case 'limit_future':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_DASHBOARD_LIMIT_FUTURE);
$propbag->add('description', '');
$propbag->add('default', '5');
break;
case 'sequence':
$propbag->add('type', 'sequence');
$propbag->add('name', PLUGIN_DASHBOARD_SEQUENCE);
$propbag->add('description', PLUGIN_DASHBOARD_SEQUENCE_DESC);
$propbag->add('checkable', true);
$values = array(
'update' => array('display' => UPDATE),
'draft' => array('display' => DRAFT),
'comments' => array('display' => COMMENT),
'future' => array('display' => PLUGIN_DASHBOARD_FUTURE),
'comments_pending' => array('display' => PLUGIN_DASHBOARD_COMMENTS_PENDING)
);
$propbag->add('values', $values);
$propbag->add('default', 'update,draft,comments_pending,comments,future');
break;
default:
return false;
}
return true;
}
function generate_content(&$title) {
$title = PLUGIN_DASHBOARD_TITLE;
}
function showElementCommentlist($where, $limit) {
global $serendipity;
$summaryLength = 200;
$i = 0;
if (version_compare(substr($serendipity['version'], 0, 3), '1.6') >= 0) {
$comments = serendipity_fetchComments(null, $limit, 'co.id DESC', true, 'NORMAL', $where);
} else {
$comments = serendipity_db_query("SELECT c.*, e.title FROM {$serendipity['dbPrefix']}comments c
LEFT JOIN {$serendipity['dbPrefix']}entries e ON (e.id = c.entry_id)
WHERE 1 = 1 " . $where
. (!serendipity_checkPermission('adminEntriesMaintainOthers') ? 'AND e.authorid = ' . (int)$serendipity['authorid'] : '') . "
ORDER BY c.id DESC LIMIT $limit");
}
if (!is_array($comments)) {
return;
}
if (count($comments)==0) {
return;
}
echo '
';
foreach ($comments as $rs) {
$i++;
$comment = array(
'fullBody' => $rs['body'],
'summary' => serendipity_mb('substr', $rs['body'], 0, $summaryLength),
'status' => $rs['status'],
'type' => $rs['type'],
'id' => $rs['id'],
'title' => $rs['title'],
'timestamp' => $rs['timestamp'],
'referer' => $rs['referer'],
'url' => $rs['url'],
'ip' => $rs['ip'],
'entry_url' => serendipity_archiveURL($rs['entry_id'], $rs['title']),
'email' => $rs['email'],
'author' => (empty($rs['author']) ? ANONYMOUS : $rs['author']),
'entry_id' => $rs['entry_id']
);
$entrylink = serendipity_archiveURL($comment['entry_id'], 'comments', 'serendipityHTTPPath', true) . '#c' . $comment['id'];
if (strlen($comment['fullBody']) > strlen($comment['summary']) ) {
$comment['summary'] .= ' ...';
$comment['excerpt'] = true;
// When summary is not the full body, strip HTML tags from summary, as it might break and leave unclosed HTML.
$comment['fullBody'] = nl2br((function_exists('serendipity_specialchars') ? serendipity_specialchars($comment['fullBody']) : htmlspecialchars($comment['fullBody'], ENT_COMPAT, LANG_CHARSET)));
$comment['summary'] = nl2br(strip_tags($comment['summary']));
} else {
$comment['excerpt'] = false;
$comment['fullBody'] = $comment['summary'] = nl2br((function_exists('serendipity_specialchars') ? serendipity_specialchars($comment['fullBody']) : htmlspecialchars($comment['fullBody'], ENT_COMPAT, LANG_CHARSET)));
}
#serendipity_plugin_api::hook_event('backend_view_comment', $comment, '&serendipity[page]='. $page . $searchString);
$class = 'serendipity_admin_list_item_' . (($i % 2 == 0 ) ? 'even' : 'uneven');
if ($comment['status'] == 'pending' || $comment['status'] === 'confirm') {
$class .= ' serendipity_admin_comment_pending';
}
$header_class = ($comment['status'] == 'pending' || $comment['status'] === 'confirm' ? 'serendipityAdminMsgNote serendipity_admin_comment_pending_header' : '');
?>
';
}
function showElementEntrylist($filter = array(), $limit = 0) {
global $serendipity;
$filter_sql = implode(' AND ', $filter);
$orderby = 'timestamp DESC';
// Fetch the entries
$entries = serendipity_fetchEntries(
false,
false,
$limit,
true,
false,
$orderby,
$filter_sql
);
$rows = 0;
if (!is_array($entries)) {
return;
}
foreach ($entries as $entry) {
$rows++;
// Find out if the entry has been modified later than 30 minutes after creation
if ($entry['timestamp'] <= ($entry['last_modified'] - 60*30)) {
$lm = '
';
} else {
$lm = '';
}
if (!$serendipity['showFutureEntries'] && $entry['timestamp'] >= serendipity_serverOffsetHour()) {
$entry_pre = '
';
} else {
$entry_pre = '';
}
if (serendipity_db_bool($entry['properties']['ep_is_sticky'])) {
$entry_pre .= ' ' . STICKY_POSTINGS . ': ';
}
if (serendipity_db_bool($entry['isdraft'])) {
$entry_pre .= ' ' . DRAFT . ': ';
}
?>
|
|
' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($cat['category_name']) : htmlspecialchars($cat['category_name'], ENT_COMPAT, LANG_CHARSET)) . '';
}
echo implode(', ', $cats);
}
$entry['link'] = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']));
$entry['preview_link'] = '?serendipity[noBanner]=true&serendipity[noSidebar]=true&serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=preview&serendipity[id]=' . $entry['id'];
?>
|
= serendipity_serverOffsetHour())) { ?>
|
get_config('limit_draft');
if ($lim < 1) return;
echo '';
echo '
' . DRAFT . '
';
$this->showElementEntrylist(array("e.isdraft = 'true'"), $lim);
echo '';
}
function compareVersion($newV, $actV) {
$newV = explode('.', $newV);
$actV = explode('.', $actV);
$length = ( count($newV) > count($actV) ? count($newV) : count($actV) );
for($i=0; $i < $length; $i++){
if ($newV[$i] > $actV[$i]){
return 1;
}
}
return 0;
}
function CheckUpdate() {
global $serendipity;
if ($this->get_config('update') == 'none') {
return;
}
$updateURL = 'https://raw.github.com/s9y/Serendipity/master/docs/RELEASE';
$file = fopen($updateURL, 'r');
if (!$file) {
echo "PLUGIN_DASHBOARD_ERROR_URL";
return;
}
$version=$this->get_config('update');
while(!feof($file)){
$line = fgets($file);
if(preg_match('/^' . $version . ':(.+$)/', $line, $match)){
$update_to_version = $match[1];
$this->set_config('last_version', $update_to_version);
if ($version == "stable"){
$url="http://prdownloads.sourceforge.net/php-blog/serendipity-" . $update_to_version . ".zip";
}
else {
if (date('H') >= 23 && date('i') >=42){
$day = date("d");
}
else {
$day = date("d") - 1;
}
$url="http://www.s9y.org/snapshots/s9y_". date("Ym") . $day . "2342.tar.gz";
}
if($this->compareVersion($update_to_version, $serendipity['version'])){
$u_text = '';
$this->set_config('update_text', $u_text);
}
}
}
}
function showElementComments() {
$lim = $this->get_config('limit_comments');
if ($lim < 1) return;
echo '';
}
function showElementCommentsPending() {
$lim = $this->get_config('limit_comments_pending');
if ($lim < 1) return;
echo '';
}
function showUpdateNotifier() {
global $serendipity;
// If we didn't check today, do it now and remeber, that we did.
if (($this->get_config('last_update') != date('Ymd'))){
$this->set_config('last_update', date('Ymd'));
$this->CheckUpdate(); // this will fill all needed config values
}
// Check if the last found update version is newer and tell it, if this is the case
$newVersion = $this->get_config('last_version');
if($this->compareVersion($newVersion, $serendipity['version'])){
$eventData = '';
serendipity_plugin_api::hook_event('plugin_dashboard_updater', $eventData, $newVersion);
print '';
print '
' . PLUGIN_DASHBOARD_UPD . '
';
$update_text = $this->get_config('update_text');
print $update_text . $eventData;
print '';
}
}
function showElementFuture() {
$lim = $this->get_config('limit_future');
if ($lim < 1) return;
echo '';
echo '
' . PLUGIN_DASHBOARD_FUTURE . '
';
$this->showElementEntrylist(array("e.isdraft != 'true' AND e.timestamp >= " . serendipity_serverOffsetHour()), $lim);
echo '';
}
function showElement($element) {
switch($element) {
case 'update':
$this->ShowUpdateNotifier();
break;
case 'draft':
$this->showElementDraft();
break;
case 'comments':
$this->showElementComments();
break;
case 'comments_pending':
$this->showElementCommentsPending();
break;
case 'future':
$this->showElementFuture();
break;
}
return true;
}
function event_hook($event, &$bag, &$eventData, $addData = null) {
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'backend_frontpage_display':
$elements = explode(',', $this->get_config('sequence'));
ob_start();
?>
showElement($element);
}
$dashboard = ob_get_contents();
ob_end_clean();
$eventData['more'] = $dashboard;
break;
case 'css_backend':
$filename = 'dashboard.css';
$tfile = serendipity_getTemplateFile($filename, 'serendipityPath');
if (!$tfile || $tfile == $filename) {
$tfile = dirname(__FILE__) . '/' . $filename;
}
echo file_get_contents($tfile);
break;
}
}
return true;
}
}
/* vim: set sts=4 ts=4 expandtab : */
' . COMMENT . '
'; $this->showElementCommentlist("AND status = 'approved'", $lim); echo '