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


PHP Blog::getBlogById方法代码示例

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


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

示例1: editBlog

function editBlog()
{
    $results = array();
    // User has not posted the article edit form yet: display the form
    $results['blog'] = Blog::getBlogById((int) $_POST['blogId']);
    include 'templates/editBlog.php';
}
开发者ID:neequole,项目名称:sp2,代码行数:7,代码来源:blogFunc.php

示例2: actionUpdate

 public static function actionUpdate($id)
 {
     $blog = Blog::getBlogById($id);
     if (!$blog) {
         $blog = array();
     }
     $errors = array();
     $title = '';
     $description = '';
     $content = '';
     if (isset($_POST['submit'])) {
         $title = FunctionLibrary::clearStr($_POST['title']);
         $description = nl2br(FunctionLibrary::clearStr($_POST['description']));
         $content = nl2br(FunctionLibrary::clearStr($_POST['content']));
         if (!User::checkName($title)) {
             $errors[] = 'Заглавие не может быть пустым.';
         }
         if (!User::checkName($description)) {
             $errors[] = 'Описание не может быть пустым.';
         }
         if (!User::checkName($content)) {
             $errors[] = 'Содержание не может быть пустым.';
         }
         if (empty($errors)) {
             $result = Blog::updateBlogById($id, $title, $description, $content);
             if (!$result) {
                 $_SESSION['message'] = 'Произошла ошибка при редактировании.';
             } else {
                 if (!empty($_FILES['image']['tmp_name'])) {
                     $tmpName = $_FILES['image']['tmp_name'];
                     if (is_uploaded_file($tmpName)) {
                         $imagePath = "/images/blog/blog{$id}.jpg";
                         $result = Blog::putImageToDataBase($id, $imagePath);
                         if ($result) {
                             $destination = ROOT . '/template' . $imagePath;
                             $moveResult = move_uploaded_file($tmpName, $destination);
                             if (!$moveResult) {
                                 $_SESSION['message'] = "Произошла ошибка при добавлении картинки.";
                             }
                         }
                     }
                 }
             }
             FunctionLibrary::redirectTo('/admin/blog');
         }
     }
     require_once ROOT . '/views/admin-blog/update.php';
     return true;
 }
开发者ID:php-user,项目名称:shop.local,代码行数:49,代码来源:AdminBlogController.php

示例3: actionView

 public function actionView($id)
 {
     $categories = Category::getCategoriesList();
     if (!$categories) {
         $categories = array();
     }
     $blog = Blog::getBlogById($id);
     if (!$blog) {
         $blog = array();
     }
     if ($blog['id'] != $id) {
         FunctionLibrary::redirectTo('/blog');
     }
     require_once ROOT . '/views/blog/view.php';
     return true;
 }
开发者ID:php-user,项目名称:shop.local,代码行数:16,代码来源:BlogController.php

示例4: viewBlog

function viewBlog()
{
    if (!isset($_GET["blogId"]) || !$_GET["blogId"]) {
        homepage();
        return;
    }
    $data = Page::getPageByTitle($_GET['action']);
    //body content
    echo "<div id='output'>";
    if ($data) {
        if ($data->page_protection == '1' && !isset($_SESSION['name'])) {
            echo "Please log-in to view this page.";
        } else {
            if ($data->page_status == 'draft') {
                echo "This page is not yet published. Contact the site admin.";
            } else {
                //show body and blog
                echo "<p>" . $data->page_body . "</p>";
                $results = array();
                $results['blog'] = Blog::getBlogById($_GET["blogId"]);
                $results['pageTitle'] = $results['blog']->title . " | Widget News";
                $row = $results['blog'];
                echo "<input type='hidden' value='" . $row->id . "' id='hBlogId'/>";
                echo '<h1 class="headSection">' . $row->title . '</h1><p class="smallText">' . $row->publicationDate . '</p><p>' . $row->content . '</p>';
                echo '<p style="font-weight:bold;">Share this!</p><a href="#"><img src="include/images/fb.png"/></a><a href="#"><img src="include/images/twit.png"/></a><a href="#"><img src="include/images/rss2.png"/></a><a href="#"><img src="include/images/google.png"/></a><a href="#"><img src="include/images/delicious.png"/></a><a href="#"><img src="include/images/stumbleupon.png"/></a><a href="#"><img src="include/images/digg.png"/></a><hr/>';
                echo '<div id="commentSection"><p class="smallText">Leave a comment...</p><textarea id="comment"  placeholder="Put your comment here" required maxlength="1000" style="height: 3em; width:90%; display: block;margin-left: auto;margin-right: auto;"></textarea><input type="button" id="submitComment" value="Post!" title="' . $_GET["blogId"] . '"/></div>';
                //existing comments
                getComment();
                //end of comment
            }
        }
    }
    echo "</div>";
    //end of body content
    //sidebar
    echo "<div id='sidebar'>";
    if ($data) {
        echo "<p>" . $data->page_sidebar . "</p>";
    }
    echo "</div>";
    //end of sidebar
}
开发者ID:neequole,项目名称:sp2,代码行数:42,代码来源:index.php


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