function plugin_lastcomments_widget() { if (false === ($f = io_load_file(LASTCOMMENTS_CACHE_FILE))) { // no comments in cache $list = array(); } else { // if file exists and its correctly read, we get the stored list // (it is stored in encoded form) $list = unserialize($f); } $content = '<ul class="last-comments">'; // cimangi Aggiunta traduzione stringhe // load plugin strings // they're located under plugin.PLUGINNAME/lang/LANGID/ $lang = lang_load('plugin:lastcomments'); if ($count = count($list)) { while ($arr = array_pop($list)) { theme_comments_filters($arr, $id); $q = new FPDB_Query(array('id' => $arr['entry']), null); // first element of the array is dropped, as it is the ID, which // we already know @(list(, $entry) = $q->getEntry($query)); if (!$entry) { $count--; $update = true; continue; } $content .= "<li>\n\t\t\t<blockquote class=\"comment-quote\" cite=\"comments.php?entry={$arr['entry']}#{$arr['id']}\">\n\t\t\t{$arr['content']}\n\t\t\t<p><a href=\"" . get_comments_link($arr['entry']) . "#{$arr['id']}\">{$arr['name']} - {$entry['subject']}</a></p>\n\t\t\t</blockquote></li>\n"; } $subject = $lang['plugin']['lastcomments']['last'] . ' ' . $count . ' ' . $lang['plugin']['lastcomments']['comments']; } if (!$count) { if ($update) { fs_delete(LASTCOMMENTS_CACHE_FILE); } $content .= '<li>' . $lang['plugin']['lastcomments']['no_comments'] . '</li>'; $subject = $lang['plugin']['lastcomments']['no_new_comments']; } $content .= '</ul>'; $entry['subject'] = $subject; $entry['content'] = $content; return $entry; }
function smarty_block_comment($params, $content, &$smarty, &$repeat) { global $fpdb; // clean old variables $smarty->assign(array('subject' => '', 'content' => '', 'date' => '', 'name' => '', 'url' => '', 'email' => '', 'version' => '', 'ip-address' => '', 'loggedin' => '')); $q =& $fpdb->getQuery(); if ($repeat = $q->comments->hasMore()) { $couplet =& $q->comments->getComment(); $id =& $couplet[0]; $comment =& $couplet[1]; foreach ($comment as $k => $v) { $kk = str_replace('-', '_', $k); $smarty->assign_by_ref($kk, $comment[$k]); } if (THEME_LEGACY_MODE) { $comment = theme_comments_filters($comment, $id); } $smarty->assign('id', $id); } return $content; }