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 increment_article_views($hook)
{
    global $news_arr;
    // get the current news ID
    $news_id = $news_arr[0];
    // Load the counters
    $xfields = new XfieldsData();
    // Increment the counter value
    $xfields->increment($news_id, VIEW_COUNT_XFIELD);
    // Save the counters
    $xfields->save();
}
Esempio n. 3
0
function clean_multiple_xfields($hook)
{
    global $selected_news;
    $xfields = new XfieldsData();
    foreach ($selected_news as $null => $news_id) {
        $xfields->delete($news_id);
    }
    $xfields->save();
}
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;
}