当前位置: 首页>>代码示例>>PHP>>正文


PHP unknown::get_posts方法代码示例

本文整理汇总了PHP中unknown::get_posts方法的典型用法代码示例。如果您正苦于以下问题:PHP unknown::get_posts方法的具体用法?PHP unknown::get_posts怎么用?PHP unknown::get_posts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unknown的用法示例。


在下文中一共展示了unknown::get_posts方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: smarty_function_getrecentposts

/**
 *
 *
 * @param unknown $params
 * @param unknown $bBlog  (reference)
 * @return unknown
 */
function smarty_function_getrecentposts($params, &$bBlog)
{
    $ar = array();
    $opt = array();
    // If "assign" is not set... we'll establish a default.
    if ($params['assign'] == '') {
        $params['assign'] = 'posts';
    }
    // If "archive" is set, order them ASCENDING by posttime.
    if ($params['archive'] == 'TRUE') {
        $opt['order'] = " ORDER BY posttime ";
    }
    // If num is set, we'll only get that many results in return
    if (is_numeric($params['num'])) {
        $opt['num'] = $params['num'];
    }
    // If skip is set, we'll skip that many results
    if (is_numeric($params['skip'])) {
        $opt['num'] = $params['skip'];
    }
    if ($params['section'] != '') {
        $opt['sectionid'] = $bBlog->sect_by_name[$params['section']];
    }
    if ($bBlog->show_section) {
        $opt['sectionid'] = $bBlog->show_section;
    }
    $opt['home'] = $params['home'];
    $q = $bBlog->make_post_query($opt);
    $ar['posts'] = $bBlog->get_posts($q);
    // No posts.
    if (!is_array($ar['posts'])) {
        return '';
    }
    $lastmonth = 0;
    $lastdate = 0;
    foreach ($ar['posts'] as $key => $value) {
        // It seems silly to do this. Especially since,
        // this kind of check can be done in Smarty template.
        // Additionally, since {newday} and {newmonth} require
        // the data to be in a variable named "post" it may not
        // function at all.
        //
        // We'll leave it here for now.
        /* check if new day  - used by block.newday.php */
        if (date('Ymd', $ar['posts'][$key]['posttime']) != $lastdate) {
            $ar['posts'][$key]['newday'] = TRUE;
        }
        $lastdate = date('Ymd', $ar['posts'][$key]['posttime']);
        /* check if new month - use by block.newmonth.php */
        if (date('Fy', $ar['posts'][$key]['posttime']) != $lastmonth) {
            $ar['posts'][$key]['newmonth'] = TRUE;
        }
        $lastmonth = date('Fy', $ar['posts'][$key]['posttime']);
    }
    $bBlog->assign($params['assign'], $ar['posts']);
    return '';
}
开发者ID:escherlat,项目名称:loquacity,代码行数:64,代码来源:function.getrecentposts.php

示例2: smarty_function_getpost

/**
 *
 *
 * @param unknown $params
 * @param unknown $bBlog  (reference)
 * @return unknown
 */
function smarty_function_getpost($params, &$bBlog)
{
    $ar = array();
    // If "assign" is not set... we'll establish a default.
    if ($params['assign'] == '') {
        $params['assign'] = 'post';
    }
    if ($params['postid'] == '') {
        $bBlog->trigger_error('postid is a required parameter');
        return '';
    }
    $q = $bBlog->make_post_query(array("postid" => $params['postid']));
    $ar['posts'] = $bBlog->get_posts($q);
    // No posts.
    if (!is_array($ar['posts'])) {
        return false;
    }
    $ar['posts'][0]['newday'] = 'yes';
    $ar['posts'][0]['newmonth'] = 'yes';
    $bBlog->assign($params['assign'], $ar['posts'][0]);
    return '';
}
开发者ID:escherlat,项目名称:loquacity,代码行数:29,代码来源:function.getpost.php

示例3: smarty_function_calendar

/**
 *
 *
 * @param unknown $params
 * @param unknown $bBlog  (reference)
 */
function smarty_function_calendar($params, &$bBlog)
{
    $date = getdate();
    $today = $date["mday"];
    $month = $date["mon"];
    $year = $date["year"];
    $new_month = $_GET["month"];
    $new_year = $_GET["year"];
    if ($new_month && $new_year) {
        $date = getdate(mktime(0, 0, 0, $new_month, 1, $new_year));
        $show_month = $date["mon"];
        $show_year = $date["year"];
    } else {
        $show_month = $month;
        $show_year = $year;
    }
    $q = $bBlog->make_post_query(array("where" => " AND month(FROM_UNIXTIME(posttime)) = {$show_month} and year(FROM_UNIXTIME(posttime)) = {$show_year} ", "num" => "999"));
    $dayindex = array();
    global $dayindex;
    $posts = $bBlog->get_posts($q);
    if (is_array($posts)) {
        foreach ($posts as $post) {
            $d = date('j', $post['posttime']);
            $dayindex[$d][] = array("id" => $post['post'], "title" => $post['title'], "url" => $bBlog->_get_entry_permalink($post['postid']));
        }
    }
    $left_year = $right_year = $show_year;
    $left_month = $show_month - 1;
    if ($left_month < 1) {
        $left_month = 12;
        $left_year--;
    }
    $right_month = $show_month + 1;
    if ($right_month > 12) {
        $right_month = 1;
        $right_year++;
    }
    $bBlog->assign("left", $_SERVER["PHP_SELF"] . "?month={$left_month}&year={$left_year}");
    $bBlog->assign("right", $_SERVER["PHP_SELF"] . "?month={$right_month}&year={$right_year}");
    $bBlog->assign("header", strftime("%B %Y", mktime(0, 0, 0, $show_month, 1, $show_year)));
    $first_date = mktime(0, 0, 0, $show_month, 1, $show_year);
    $date = getdate($first_date);
    $first_wday = $date["wday"];
    $last_date = mktime(0, 0, 0, $show_month + 1, 0, $show_year);
    $date = getdate($last_date);
    $last_day = $date["mday"];
    $wday = "";
    // echo($params["locale"]);
    if ($params["locale"]) {
        @setlocale(LC_TIME, $params["locale"]);
    }
    $week_start = $params["week_start"];
    if ($week_start < 0 || $week_start > 6) {
        $week_start = 1;
    }
    for ($counter = $week_start; $counter < $week_start + 7; $counter++) {
        if ($counter > 6) {
            $wday[] = strftime("%a", mktime(0, 0, 0, 3, $counter - 7, 2004));
        } else {
            $wday[] = strftime("%a", mktime(0, 0, 0, 3, $counter, 2004));
        }
    }
    $bBlog->assign("wday", $wday);
    $week_array = "";
    $month_array = "";
    $pre_counter = $first_wday - $week_start;
    if ($pre_counter < 0) {
        $pre_counter += 7;
    }
    $day = 1;
    while (true) {
        $week_array = "";
        for ($counter = 0; $counter < 7; $counter++) {
            if ($day > $last_day) {
                $week_array[] = array(0 => false, 1 => "&nbsp;", 2 => false);
            } else {
                if ($pre_counter > 0) {
                    $week_array[] = array(0 => false, 1 => "&nbsp;", 2 => false);
                    $pre_counter--;
                } else {
                    getDateLink($day, &$values);
                    $week_array[] = array(0 => $dayindex["{$day}"] ? true : false, 1 => $day, 2 => $day == $today && $month == $show_month && $year == $show_year ? true : false);
                    $day++;
                }
            }
        }
        $month_array[] = $week_array;
        if ($day > $last_day) {
            break;
        }
    }
    $bBlog->assign("month", $month_array);
    $bBlog->assign("values", $values);
    $bBlog->display("calendar.html", FALSE);
//.........这里部分代码省略.........
开发者ID:escherlat,项目名称:loquacity,代码行数:101,代码来源:function.calendar.php

示例4: smarty_function_getarchiveposts

/**
 *
 *
 * @param unknown $params
 * @param unknown $bBlog  (reference)
 * @return unknown
 */
function smarty_function_getarchiveposts($params, &$bBlog)
{
    $ar = array();
    $opt = array();
    // If "assign" is not set... we'll establish a default.
    if ($params['assign'] == '') {
        $params['assign'] = 'posts';
    }
    // If "archive" is set, order them ASCENDING by posttime.
    if ($params['archive']) {
        $opt['order'] = " ORDER BY posttime ";
    }
    if (is_numeric($params['num'])) {
        $opt['num'] = $params['num'];
    }
    if (is_numeric($params['year'])) {
        if (strlen($params['year']) != 4) {
            $bBlog->trigger_error('getarchiveposts: year parameter requires a 4 digit year');
            return '';
        }
        $opt['year'] = $params['year'];
    }
    if (is_numeric($params['month'])) {
        if (strlen($params['month']) != 2) {
            $bBlog->trigger_error('getarchiveposts: month parameter requires a 2 digit month');
            return '';
        }
        $opt['month'] = $params['month'];
    }
    if (is_numeric($params['day'])) {
        if (strlen($params['day']) != 2) {
            $bBlog->trigger_error('getarchiveposts: day parameter requires a 2 digit day');
            return '';
        }
        $opt['day'] = $params['day'];
    }
    if (is_numeric($params['hour'])) {
        if (strlen($params['hour']) != 2) {
            $bBlog->trigger_error('getarchiveposts: hour parameter requires a 2 digit hour');
            return '';
        }
        $opt['hour'] = $params['hour'];
    }
    if (is_numeric($params['minute'])) {
        if (strlen($params['minute']) != 2) {
            $bBlog->trigger_error('getarchiveposts: minute parameter requires a 2 digit minute');
            return '';
        }
        $opt['minute'] = $params['minute'];
    }
    if (is_numeric($params['second'])) {
        if (strlen($params['second']) != 2) {
            $bBlog->trigger_error('getarchiveposts: second parameter requires a 2 digit second');
            return '';
        }
        $opt['second'] = $params['second'];
    }
    if ($params['section'] != '') {
        $opt['sectionid'] = $bBlog->sect_by_name[$params['section']];
    }
    $q = $bBlog->make_post_query($opt);
    $ar['posts'] = $bBlog->get_posts($q);
    // No posts.
    if (!is_array($ar['posts'])) {
        return '';
    }
    $lastmonth = '';
    $lastdate = '';
    foreach ($ar['posts'] as $key => $value) {
        // It seems silly to do this. Especially since,
        // this kind of check can be done in Smarty template.
        // Additionally, since {newday} and {newmonth} require
        // the data to be in a variable named "post" it may not
        // function at all.
        //
        // We'll leave it here for now.
        if (date('Fy', $ar['posts'][$key]['posttime']) != $lastmonth) {
            $ar['posts'][$key]['newmonth'] = 'yes';
        }
        $lastmonth = date('Fy', $ar['posts'][$key]['posttime']);
        if (date('Ymd', $ar['posts'][$key]['posttime']) != $lastdate) {
            $ar['posts'][$key]['newday'] = 'yes';
        }
        $lastdate = date('Ymd', $ar['posts'][$key]['posttime']);
    }
    $bBlog->assign($params['assign'], $ar['posts']);
    return '';
}
开发者ID:escherlat,项目名称:loquacity,代码行数:95,代码来源:function.getarchiveposts.php

示例5: smarty_function_recentposts

/**
 *
 *
 * @param unknown $params
 * @param unknown $bBlog  (reference)
 * @return unknown
 */
function smarty_function_recentposts($params, &$bBlog)
{
    $num = 5;
    $mode = "br";
    $sep = "<br />";
    $titlelen = 30;
    $skip = 0;
    $linkcode = '';
    if (isset($params['sep'])) {
        $sep = $params['sep'];
    }
    if (isset($params['num'])) {
        $num = $params['num'];
    }
    if (isset($params['mode'])) {
        $mode = $params['mode'];
    }
    if (isset($params['skip'])) {
        $skip = $params['skip'];
    }
    if (isset($params['titlelen'])) {
        $titlelen = $params['titlelen'];
    }
    $q = $bBlog->make_post_query(array("num" => $num, "skip" => $skip));
    $posts = $bBlog->get_posts($q);
    if ($mode == "list") {
        $linkcode .= "<ul>";
    }
    $i = 0;
    if (is_array($posts)) {
        /* <a([^<]*)?href=(\"|')?([a-zA-Z]*://[a-zA-Z0-9]*\.[a-zA-Z0-9]*\.[a-zA-Z]*([^>]*)?)(\"|')?([^>]*)?>([^<]*)</a> */
        // This should match any protocol, any port, any URL, any title. URL's like www.yest.com are supported, and should be treated as HTTP by browsers.
        $regex = "#<a([^<]*)?href=(\"|')?(([a-zA-Z]*://)?[a-zA-Z0-9]*\\.[a-zA-Z0-9]*\\.[a-zA-Z]*(:[0-9]*)?([^>\"\\']*)?)(\"|')?([^>]*)?>([^<]*)</a>#i";
        foreach ($posts as $post) {
            $title = $post["title"];
            $fulltitle = $title;
            //wont be cut off
            if (preg_match($regex, $title, $matches) == 1) {
                $title = $matches[9];
            }
            $i++;
            if ($mode == "list") {
                $linkcode .= "<li>";
            }
            // we using arrays in the template and objects in the core..
            $url = $post['permalink'];
            $title = truncate($title, $titlelen, '...', FALSE);
            $linkcode .= "<a href='{$url}' title='{$fulltitle}'>{$title}</a>";
            if ($mode == "br" && $num > $i) {
                $linkcode .= $sep;
            }
            if ($mode == "list") {
                $linkcode .= "</li>";
            }
        }
    }
    if ($mode == "list") {
        $linkcode .= "</ul>";
    }
    return $linkcode;
}
开发者ID:escherlat,项目名称:loquacity,代码行数:68,代码来源:function.recentposts.php

示例6: smarty_function_getposts

/**
 *
 *
 * @param unknown $params
 * @param unknown $bBlog  (reference)
 * @return unknown
 */
function smarty_function_getposts($params, &$bBlog)
{
    $ar = array();
    $opt = array();
    if (is_numeric($params['postid']) && $params['postid'] > 0) {
        $postid = $params['postid'];
    } else {
        $postid = FALSE;
    }
    // If "assign" is not set... we'll establish a default.
    if ($params['assign'] == '') {
        if ($postid) {
            $params['assign'] = 'post';
        } else {
            $params['assign'] = 'posts';
        }
    }
    if ($postid) {
        //we've been given a post id so we'll just get it and get outta here.
        $q = $bBlog->make_post_query(array("postid" => $params['postid']));
        $ar['posts'] = $bBlog->get_posts($q);
        // No post.
        if (!is_array($ar['posts'])) {
            return false;
        }
        $ar['posts'][0]['newday'] = 'yes';
        $ar['posts'][0]['newmonth'] = 'yes';
        $bBlog->assign($params['assign'], $ar['posts'][0]);
        return '';
        // so if postid is given this is the last line processed
    }
    // If "archive" is set, order them ASCENDING by posttime.
    if ($params['archive']) {
        $opt['order'] = " ORDER BY posttime ";
    }
    // If num is set, we'll only get that many results in return
    if (is_numeric($params['num'])) {
        $opt['num'] = $params['num'];
    }
    // If skip is set, we'll skip that many results
    if (is_numeric($params['skip'])) {
        $opt['skip'] = $params['skip'];
    }
    if ($params['section'] != '') {
        $opt['sectionid'] = $bBlog->sect_by_name[$params['section']];
    }
    if ($bBlog->show_section) {
        $opt['sectionid'] = $bBlog->show_section;
    }
    if (is_numeric($params['year'])) {
        if (strlen($params['year']) != 4) {
            $bBlog->trigger_error('getposts: year parameter requires a 4 digit month');
            return '';
        }
        $opt['year'] = $params['year'];
    }
    if (is_numeric($params['month'])) {
        if (strlen($params['month']) != 2) {
            $bBlog->trigger_error('getposts: month parameter requires a 2 digit month');
            return '';
        }
        $opt['month'] = $params['month'];
    }
    if (is_numeric($params['day'])) {
        if (strlen($params['day']) != 2) {
            $bBlog->trigger_error('getposts: day parameter requires a 2 digit day');
            return '';
        }
        $opt['day'] = $params['day'];
    }
    if (is_numeric($params['hour'])) {
        if (strlen($params['hour']) != 2) {
            $bBlog->trigger_error('getposts: hour parameter requires a 2 digit hour');
            return '';
        }
        $opt['hour'] = $params['hour'];
    }
    if (is_numeric($params['minute'])) {
        if (strlen($params['minute']) != 2) {
            $bBlog->trigger_error('getposts: minute parameter requires a 2 digit minute');
            return '';
        }
        $opt['minute'] = $params['minute'];
    }
    if (is_numeric($params['second'])) {
        if (strlen($params['second']) != 2) {
            $bBlog->trigger_error('getposts: second parameter requires a 2 digit second');
            return '';
        }
        $opt['second'] = $params['second'];
    }
    $opt['home'] = $params['home'];
    $q = $bBlog->make_post_query($opt);
//.........这里部分代码省略.........
开发者ID:escherlat,项目名称:loquacity,代码行数:101,代码来源:function.getposts.php

示例7: admin_plugin_sections_run

/**
 *
 *
 * @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);
}
开发者ID:escherlat,项目名称:loquacity,代码行数:72,代码来源:admin.sections.php


注:本文中的unknown::get_posts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。