コード例 #1
0
/**
 *
 *
 * @param unknown $params
 * @param unknown $bBlog  (reference)
 */
function smarty_function_getcontent($params, &$bBlog)
{
    // Retrieving data
    $bBlog->get_sections();
    $sections = $bBlog->sections;
    foreach ($sections as $object) {
        $new[$object->sectionid] = $object;
    }
    $sections = $new;
    $current_section = $bBlog->get_template_vars("sectionid");
    // Return
    $bBlog->assign("content", $sections[$current_section]->content);
}
コード例 #2
0
/**
 *
 *
 * @param unknown $bBlog (reference)
 */
function admin_plugin_rssfeedmaker_run(&$bBlog)
{
    if (isset($_POST['sub']) && $_POST['sub'] == 'y') {
        $url = BLOGURL . 'rss.php?';
        if ($_POST['version'] == 2) {
            $url .= 'ver=2';
        } elseif ($_POST['version'] == 'atom03') {
            $url .= 'ver=atom03';
        } else {
            $url .= 'ver=0.92';
        }
        if (is_numeric($_POST['num'])) {
            $url .= '&num=' . $_POST['num'];
        }
        if ($_POST['sectionid'] > 0) {
            $url .= '&sectionid=' . $_POST['sectionid'];
        }
        if (is_numeric($_POST['year'])) {
            $url .= '&year=' . $_POST['year'];
        }
        if (is_numeric($_POST['month'])) {
            $url .= '&year=' . $_POST['day'];
        }
        if (is_numeric($_POST['day'])) {
            $url .= '&year=' . $_POST['day'];
        }
        $bBlog->assign('results', TRUE);
        $bBlog->assign('feedurl', $url);
    }
    $sections = $bBlog->get_sections();
    $sectionlist = '';
    foreach ($sections as $section) {
        $sectionlist .= "<option value='{$section->sectionid}'>{$section->nicename}</option>";
    }
    $bBlog->assign('sectionlist', $sectionlist);
}
コード例 #3
0
/**
 *
 *
 * @param unknown $params
 * @param unknown $bBlog  (reference)
 * @return unknown
 */
function smarty_function_getsections($params, &$bBlog)
{
    if (!T_SECTIONS) {
        die("Some problem around the definition of T_SECTION");
    }
    // Temporary bugtrap to see if i'm right. (lordwo)
    // Default values
    if (!isset($params['limit'])) {
        $params['limit'] = 'both';
    }
    if (isset($params['separator'])) {
        $params['after'] = $params['separator'];
        $params['before'] = '';
    }
    // Retrieving data
    $bBlog->get_sections();
    // Generating links
    $i = 0;
    foreach ($bBlog->sections as $row) {
        if ($params['limit'] == 'both') {
            $print = TRUE;
        } elseif ($params['limit'] == 'content' && $row->content != '') {
            $print = TRUE;
        } elseif ($params['limit'] == 'blog' && $row->content == '') {
            $print = TRUE;
        } else {
            $print = FALSE;
        }
        if ($print == TRUE) {
            $i++;
            $returned_values .= $params['before'] . "<a href='?sectionid=" . $row->sectionid . "'>" . $row->nicename . "</a>" . $params['after'];
        }
    }
    // Return
    return $returned_values;
}
コード例 #4
0
/**
 *
 *
 * @param unknown $bBlog (reference)
 */
function admin_plugin_sections_run(&$bBlog)
{
    // Again, the plugin API needs work.
    if (isset($_GET['sectdo'])) {
        $sectdo = $_GET['sectdo'];
    } elseif (isset($_POST['sectdo'])) {
        $sectdo = $_POST['sectdo'];
    } else {
        $sectdo = '';
    }
    switch ($sectdo) {
        case 'new':
            // sections are being editied
            $bBlog->query("insert into " . T_SECTIONS . "\n\t\t\tset nicename='" . my_addslashes($_POST['nicename']) . "',\n\t\t\tname='" . my_addslashes($_POST['urlname']) . "'");
            $insid = $bBlog->insert_id;
            $bBlog->get_sections();
            // update the section cache
            break;
        case "Delete":
            // delete section
            // have to remove all references to the section in the posts
            $sect_id = $bBlog->sect_by_name[$_POST['sname']];
            if ($sect_id > 0) {
                //
                $posts_in_section_q = $bBlog->make_post_query(array("sectionid" => $sect_id));
                $posts_in_section = $bBlog->get_posts($posts_in_section_q, TRUE);
                if ($posts_in_section) {
                    foreach ($posts_in_section as $post) {
                        unset($tmpr);
                        $tmpr = array();
                        $tmpsections = explode(":", $post->sections);
                        foreach ($tmpsections as $tmpsection) {
                            if ($tmpsection != $sect_id) {
                                $tmpr[] = $tmpsection;
                            }
                        }
                        $newsects = implode(":", $tmpr);
                        // update the posts to remove the section
                        $bBlog->query("update " . T_POSTS . " set sections='{$newsects}'\n                                \twhere postid='{$post->postid}'");
                    }
                    // end foreach ($post_in_section as $post)
                }
                // end if($posts_in_section)
                // delete the section
                //$bBlog->get_results("delete from ".T_SECTIONS." where sectionid='$sect_id'");
                $bBlog->query("delete from " . T_SECTIONS . " where sectionid='{$sect_id}'");
                //echo "delete from ".T_SECTIONS." where sectionid='$sect_id'";
                $bBlog->get_sections();
                //$bBlog->debugging=TRUE;
            }
            // else show error
        // else show error
        case "Save":
            $sect_id = $bBlog->sect_by_name[$_POST['sname']];
            if ($sect_id < 1) {
                break;
            }
            $bBlog->query("update " . T_SECTIONS . " set nicename='" . my_addslashes($_POST['nicename']) . "'\n                        where sectionid='{$sect_id}'");
            $bBlog->get_sections();
            // update section cache
            break;
        default:
            // show form
            break;
    }
    $bBlog->assign('esections', $bBlog->sections);
}