function fs_ApplyFormat($content, $hook) { global $news_arr, $id, $fs_formats; if (isset($_POST['fs_format'])) { $format = $_POST['fs_format']; } else { // get the current news ID $news_id = $news_arr[0]; # fix for comments if (!$news_id or $news_id == "") { $news_id = $id; } // Load all the xfield data $xfields = new XfieldsData(); // Get the Format for the current news ID $format = $xfields->fetch($news_id, FS_FORMAT_XFIELD); } // Get the function name $format_function = $fs_formats[$format]; // Swap the strange formatting thing $content = str_replace('{nl}', "\n", $content); if (!$format_function || !function_exists($format_function)) { $format_function = $fs_formats[FS_DEFAULT_FORMAT]; } // Run the formatting function $content = $format_function($content); return $content; }
function count_article_views($entry, $hook) { global $news_arr; // define the new template code $template_code = '{views}'; // get the current news ID $news_id = $news_arr[0]; // Load all the xfield data $xfields = new XfieldsData(); // Get the counter value for the current news ID $view_count = (int) $xfields->fetch($news_id, VIEW_COUNT_XFIELD); // replace the template code with the number of views $entry = str_replace($template_code, $view_count, $entry); // return the newly formatted entry return $entry; }
function edit_tbs($hook) { global $id, $bg, $_POST; if ($_POST['deletetb'] == "yes") { $xfdel = new XfieldsData(); $arraytbs = $xfdel->fetch($id, 'trackbacks'); foreach ($_POST['deltbid'] as $null => $thisid) { unset($arraytbs[$thisid]); } $xfdel->set($arraytbs, $id, 'trackbacks'); $xfdel->save(); } echo <<<JSCRIPT <script type="text/javascript"> <!-- function check_uncheck_all_tbs() { \tvar frm = document.trackbacks; \tfor (var i=0;i<frm.elements.length;i++) { \t\tvar elmnt = frm.elements[i]; \t\tif (elmnt.type=='checkbox') { \t\t\tif(frm.cmbox.checked == true){ elmnt.checked=true; } else{ elmnt.checked=false; } \t\t} \t} \tif(frm.cmbox.checked == true){ frm.cmbox.checked = true; } else{ frm.cmbox.checked = false; } } --> </script> JSCRIPT; echo "<table>\t\r\n\t<tr>\r\n\t<td colspan=\"3\">\r\n\t<h1>Trackbacks</h1>\r\n\t</td>\r\n\t</tr>\r\n\t<tr>"; $xf = new XfieldsData(); $arrayoftbs = $xf->fetch($id, 'trackbacks'); if (empty($arrayoftbs)) { echo "<td colspan=\"3\"><h2>No Trackbacks</h2></td></tr></table>"; } else { echo "<td style=\"padding-right: 10px;\"><h2>Blog's Name</h2></td><td style=\"padding-right: 10px;\"><h2>Time Tracked</h2></td></tr>"; echo '<form method="post" name="trackbacks" action="' . $PHP_SELF . '">'; foreach ($arrayoftbs as $time => $tbarray) { if ($flag == 1) { $bg = "alternate"; $flag = 0; } else { $bg = "alternate2"; $flag = 1; } $tbtime = date("D, d F Y h:i:s", $time); echo "<td class=\"{$bg}\"><a href=\"" . stripslashes($tbarray['url']) . "\" target=\"_blank\">" . stripslashes($tbarray['blog_name']) . "</a></td><td class=\"{$bg}\">" . $tbtime . "<td class=\"{$bg}\"><input type=\"checkbox\" name=\"deltbid[]\" value=\"{$time}\" /></td></tr>"; } echo "<tr><td></td><td><p style=\"text-align:right;\">delete all?</p></td><td><input type=\"checkbox\" name=\"cmbox\" value=\"all\" onclick=\"javascript:check_uncheck_all_tbs()\" /></td></tr><tr><td></td><td colspan=\"2\"><p style=\"text-align:right;\"><input type=\"submit\" value=\"Delete Selected\" /></p></td>"; echo "<input type=\"hidden\" name=\"newsid\" value=\"{$id}\" /><input type=\"hidden\" name=\"deletetb\" value=\"yes\" /><input type=\"hidden\" name=\"action\" value=\"editnews\" /><input type=\"hidden\" name=\"mod\" value=\"editnews\" /></form>"; echo "</table>"; } }
function edc_stopadd($allow_add_comment) { global $id; $xfields = new XfieldsData(); $stop = $xfields->fetch($id, EDC_STOPCOMMENTS_FIELD); $allow = $xfields->fetch($id, EDC_STOPCOMMENTS_FIELD); if ($stop == "yes" or $allow == "off") { $allow_add_comment = false; } return $allow_add_comment; }