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


PHP Post::getAll方法代码示例

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


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

示例1: index

 /**
  * Show a list of all the blog posts.
  *
  * @return View
  */
 public function index()
 {
     // Title
     $title = Lang::get('admin.blogs.title.blog_management');
     // Grab all the blog posts
     $posts = $this->blogRepository->getAll();
     // Show the page
     $this->render('admin.blogs.index', compact('posts', 'title'));
 }
开发者ID:christiannwamba,项目名称:laravel-site,代码行数:14,代码来源:AdminBlogsController.php

示例2: showAllPosts

 public function showAllPosts()
 {
     $post = new Post();
     $posts = $post->getAll();
     $view = new PostView();
     $view->renderPosts($posts);
 }
开发者ID:jpirih,项目名称:Php,代码行数:7,代码来源:PostControler.php

示例3: controlerJob

 public function controlerJob($maincont)
 {
     // récupération des données
     if (!$maincont->isLoggued()) {
         $maincont->goModule("home", "display");
     }
     // récupération de tous les tags pour le nuage
     $at = Tag::getAll();
     $alltags = array();
     foreach ($at as $ta) {
         $alltags[] = $ta->getTag();
     }
     // récupération des années
     $ay = Post::getAll();
     $allyears = array();
     foreach ($ay as $ye) {
         $couranty = explode("-", $ye->getDate());
         $couranty = $couranty[0];
         if (!in_array($couranty, $allyears)) {
             $allyears[] = $couranty;
         }
     }
     // login
     if ($maincont->isLoggued()) {
         $login = $_SESSION["login"];
     } else {
         $login = "nobody";
     }
     // edition d'un article existant
     if (isset($_GET['id']) && $_GET['id'] >= 0) {
         $id = $_GET['id'];
         $mode = "update";
         $title = "Edition d'un article";
         $post = Post::getById($id);
         $post = $post[0];
         // récupération des tags
         $tags = array();
         if ($mode == "update") {
             $listTag = $post->getTags();
             for ($i = 0; $i < count($post->getTags()); $i++) {
                 $t = Tag::getById($listTag[$i]->id);
                 $tags[$i] = $t[0]->getTag();
             }
         }
         $posttitle = $post->getTitle();
         $postbody = $post->getBody();
     } else {
         $id = "-1";
         $mode = "create";
         $title = "Création d'un article";
         $tags = array("tag1", "tag2", "tag3");
         $posttitle = "Votre titre";
         $postbody = "Votre contenu";
     }
     // affichage de la vue édition
     include_once "view.php";
     $v = new PostEditorView();
     $v->display($login, $alltags, $allyears, $posttitle, $postbody, $tags, $mode, $title, $id);
 }
开发者ID:rogerwilko,项目名称:Yet-Another-Blog,代码行数:59,代码来源:controler.php

示例4: controlerJob

 public function controlerJob($maincont)
 {
     // récupération des données
     if (!$maincont->isLoggued()) {
         $maincont->goModule("home", "display");
     }
     $liste = Comment::getByPublished("0");
     // on récupère les commentaires non validés
     // récupération des données des commentaires
     $coms = array();
     for ($i = 0; $i < count($liste); $i++) {
         $c = Comment::getById($liste[$i]->id);
         $c = $c[0];
         /*$coms[$i] = array('date'=>"Le ".$c->getDate()." à ".$c->getHour(),
         		 'author'=>$c->getAuthor(),
         		 'content'=>$c->getBody(),
         			 'postitle'=>''.$c->getPost()->getTitle()
         		);*/
         $coms[$i] = array("contenu" => "De : " . $c->getAuthor() . ", contenu : \"" . $c->getBody() . "\", sur l'article : " . $c->getPost()->getTitle(), "id" => $c->id);
     }
     // récupération de tous les tags pour le nuage
     $at = Tag::getAll();
     $alltags = array();
     foreach ($at as $ta) {
         $alltags[] = $ta->getTag();
     }
     // récupération des années
     $ay = Post::getAll();
     $allyears = array();
     foreach ($ay as $ye) {
         $couranty = explode("-", $ye->getDate());
         $couranty = $couranty[0];
         if (!in_array($couranty, $allyears)) {
             $allyears[] = $couranty;
         }
     }
     // login
     if ($maincont->isLoggued()) {
         $login = $_SESSION["login"];
     } else {
         $login = "nobody";
     }
     // affichage de la vue
     include_once "view.php";
     $v = new CommentAdminView();
     $v->display($login, $alltags, $allyears, $coms);
 }
开发者ID:rogerwilko,项目名称:Yet-Another-Blog,代码行数:47,代码来源:controler.php

示例5: find

 public function find($string = "")
 {
     if (!is_dir('index')) {
         throw new Exception("No search index.");
     }
     $index = scandir('index');
     $hits = array();
     foreach ($index as $pif) {
         if ($pif != '.' and $pif != '..') {
             $content = file_get_contents("index/" . $pif);
             $string = strtolower($string);
             if (preg_match("/{$string}/", $content)) {
                 $hits[] = $pif;
             }
         }
     }
     if (empty($hits)) {
         return false;
     }
     $hits = Post::getAll($hits);
     return $hits;
 }
开发者ID:ringe,项目名称:RAS,代码行数:22,代码来源:Search.class.php

示例6: _list

 public static function _list()
 {
     $warning = "";
     if (isset($_POST['delete_post'])) {
         ///check if a user is logged in and if the logged in user is the one that wrote the blog post
         if (isset($_SESSION['user_id']) && $_SESSION['user_id'] == $_POST['user_id']) {
             Post::destroy($_POST['id']);
         } else {
             $warning = 'Sorry, you do not have permissions to delete that post';
         }
     }
     if (isset($_POST['update_post'])) {
         ///check if a user is logged in and if the logged in user is the one that wrote the blog post
         if (isset($_SESSION['user_id']) && $_SESSION['user_id'] == $_POST['user_id']) {
             Post::edit($_POST, $_POST['id']);
         } else {
             $warning = 'Sorry, you do not have permissions to edit that post';
         }
     }
     if (isset($_POST['create_post'])) {
         ///check if a user is logged in
         if (isset($_SESSION['user_id'])) {
             $_POST['user_id'] = $_SESSION['user_id'];
             Post::create($_POST);
         } else {
             $warning = 'Sorry, you must be logged in to submit a post';
         }
     }
     $posts_array = Post::getAll();
     if ($posts_array) {
         foreach ($posts_array as $post) {
             $blogger = Blogger::getOne($post['user_id']);
             $post['username'] = $blogger['username'];
         }
     }
     return array('posts' => $posts_array, 'warning' => $warning);
 }
开发者ID:SafirX,项目名称:gdi-php-mvc,代码行数:37,代码来源:post.php

示例7: getPage

 function getPage()
 {
     //Create instances
     $language = new Language();
     $template = new Template();
     $post = new Post();
     $user = new User();
     //getAvailableLanguages
     $availableLanguages = $language->getAvailableLanguages();
     //getAvailableTemplates
     $availableTemplates = $template->getAvailableTemplates();
     //Get requestedLanguage & requestedTemplate
     $urlParts = explode('/', $_GET['__cap']);
     //Set requestedLanguage
     if (!isset($urlParts[2]) || $urlParts[2] === 'index.php' || $urlParts[2] === '') {
         //Get browserLanguage
         $browserLanguage = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
         if (in_array($browserLanguage, $availableLanguages, true)) {
             header('Location: ' . PROTOCOL . '://' . $_SERVER['HTTP_HOST'] . PATH_OFFSET . '/' . $browserLanguage);
         } else {
             header('Location: ' . PROTOCOL . '://' . $_SERVER['HTTP_HOST'] . PATH_OFFSET . '/' . $availableLanguages[0]);
         }
     } else {
         if (in_array($urlParts[2], $availableLanguages, true)) {
             $requestedLanguage = $urlParts[2];
         } else {
             header('Location: ' . PROTOCOL . '://' . $_SERVER['HTTP_HOST'] . PATH_OFFSET . '/' . $availableLanguages[0]);
         }
     }
     //Set default site
     $defaultSite = 'Location: ' . PROTOCOL . '://' . $_SERVER['HTTP_HOST'] . PATH_OFFSET . '/' . $requestedLanguage . '/' . $availableTemplates[0];
     //Set requestedTemplate
     if (isset($urlParts[3])) {
         if (in_array($urlParts[3], $availableTemplates, true)) {
             $requestedTemplate = $urlParts[3];
         } else {
             header($defaultSite);
         }
     } else {
         header($defaultSite);
     }
     //Set requestedParameter
     if (isset($urlParts[4])) {
         $requestedParameter = $urlParts[4];
     }
     //getLanguageArray by requestedLanguage
     $languageArray = $language->getLanguageArray($requestedLanguage);
     //getTemplate by requestedTemplate
     $page = $template->getTemplate($requestedTemplate);
     switch ($requestedTemplate) {
         case 'Admin':
             Bloggy::checkSessionRedirect($defaultSite);
             Bloggy::checkAdminRedirect($defaultSite);
             $contentAccounts = null;
             $users = $user->getAll();
             foreach ($users as $key => $value) {
                 $entry = file_get_contents(DOCUMENT_ROOT . '/template/account_entry.html');
                 $entry = str_replace('{ACCOUNT_DELETE_HREF}', 'DoDeleteAccount/' . $value['id'], $entry);
                 $entry = str_replace('{TXT_ACCOUNT_NAME}', $value['name'], $entry);
                 $entry = str_replace('{TXT_ACCOUNT_ISADMIN}', $value['isAdmin'], $entry);
                 $contentAccounts = $contentAccounts . $entry;
             }
             $page = str_replace('{ACCOUNT_ENTRIES}', $contentAccounts, $page);
             $contentPosts = null;
             $posts = $post->getAll();
             foreach ($posts as $key => $value) {
                 $entry = file_get_contents(DOCUMENT_ROOT . '/template/posts_entry.html');
                 $entry = str_replace('{POSTS_EDIT_HREF}', 'Edit/' . $value['id'], $entry);
                 $entry = str_replace('{POSTS_LINK_HREF}', 'Detail/' . $value['id'], $entry);
                 $entry = str_replace('{POSTS_DELETE_HREF}', 'DoDeletePost/' . $value['id'], $entry);
                 $entry = str_replace('{TXT_POSTS_TITLE}', $value['title'], $entry);
                 $entry = str_replace('{TXT_POSTS_SUBTITLE}', $value['subTitle'], $entry);
                 $entry = str_replace('{TXT_POSTS_MODIFIED}', $value['modifiedDate'], $entry);
                 $contentPosts = $contentPosts . $entry;
             }
             $page = str_replace('{POST_ENTRIES}', $contentPosts, $page);
             break;
         case 'Account':
             Bloggy::checkSessionRedirect($defaultSite);
             $content = null;
             $user = $user->getEntryById($_SESSION['userId']);
             $entry = file_get_contents(DOCUMENT_ROOT . '/template/account_entry.html');
             $entry = str_replace('{ACCOUNT_DELETE_HREF}', 'DoDeleteAccount/' . $user['id'], $entry);
             $entry = str_replace('{TXT_ACCOUNT_NAME}', $user['name'], $entry);
             $entry = str_replace('{TXT_ACCOUNT_ISADMIN}', $user['isAdmin'], $entry);
             $content = $content . $entry;
             $page = str_replace('{ACCOUNT_ENTRIES}', $content, $page);
             break;
         case 'Create':
             Bloggy::checkSessionRedirect($defaultSite);
             break;
         case 'Detail':
             $entry = $post->getEntryById($requestedParameter);
             $page = str_replace('{TXT_POST_IMAGE}', $entry['imagePath'], $page);
             $page = str_replace('{TXT_POST_AUTHOR}', $post->getAuthorNameById($entry['author']), $page);
             $page = str_replace('{TXT_POST_DATE}', $entry['creationDate'], $page);
             $page = str_replace('{TXT_POST_TITLE}', $entry['title'], $page);
             $page = str_replace('{TXT_POST_SUBTITLE}', $entry['subTitle'], $page);
             $page = str_replace('{TXT_POST_CONTENT}', $entry['content'], $page);
             break;
//.........这里部分代码省略.........
开发者ID:LazuLitee,项目名称:bloggy,代码行数:101,代码来源:Bloggy.class.php

示例8:

<?php

require_once 'includes/config.inc.php';
$posts = Post::getAll();
require_once VIEW_PATH . 'index.view.php';
开发者ID:hxkclan,项目名称:webiq.assignment,代码行数:5,代码来源:index.php

示例9: array

require_once __DIR__ . '/../models/Author.php';
use Symfony\Component\HttpFoundation\Request;
//Symfony2 namespace,
// needed for post requests
$app = new Silex\Application();
// Create the Silex application, in which all
//configuration is going to go
// Section A
$app['debug'] = true;
$app->register(new Silex\Provider\DoctrineServiceProvider(), array('db.options' => array('driver' => 'pdo_mysql', 'host' => 'localhost', 'dbname' => 'starappleblog', 'username' => 'root', 'password' => 'root')));
$app->register(new Silex\Provider\UrlGeneratorServiceProvider());
//$twig = new Twig_Environment($loader, array('debug' => true));
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../templates', 'twig.options' => array('cache' => false)));
$app->get('/', function () use($app) {
    $postModel = new Post($app['db']);
    $postsToDisplay = $postModel->getAll();
    return $app['twig']->render('post_index.html.twig', array('posts' => $postsToDisplay));
})->bind('post_index');
// name the route so it can be referred to
$app->get('/post/{post_id}', function ($post_id) use($app) {
    $postModel = new Post($app['db']);
    $postToDisplay = $postModel->get($post_id);
    if (!$postToDisplay) {
        $app->abort(404, 'The article could not be found');
    }
    return $app['twig']->render('post_single.html.twig', array('post' => $postToDisplay));
})->assert('post_id', '\\d+')->bind('post_single');
$app->get('/post/new', function () use($app) {
    $authorModel = new Author($app['db']);
    $authorsToDisplay = $authorModel->getAll();
    return $app['twig']->render('post_new.html.twig', array('authors' => $authorsToDisplay));
开发者ID:marchage,项目名称:phpsilexblog,代码行数:31,代码来源:index.php

示例10: json_encode

<?php

//获取分享帖子的列表,输入deleted参数值为true时,返回回收站中的帖子,值为false时,返回未删除的帖子
require_once "Post.class.php";
$deleted = $_GET["deleted"];
$post = new Post();
if ($deleted == "true") {
    $result = $post->getTrash();
} else {
    $result = $post->getAll();
}
$post->closeDB();
echo json_encode($result);
开发者ID:sleepyycat,项目名称:WebFramework,代码行数:13,代码来源:get_post_list.php

示例11: controlerJob

 public function controlerJob($maincont)
 {
     // récupération des données
     // par tags
     if (isset($_GET["tag"])) {
         $t = $_GET["tag"];
         // récupération de l'objet tag
         $thetag = Tag::getByTag("{$t}");
         $thetag = $thetag[0];
         $title = "Liste des posts avec le tag {$t}";
         // récupération de la liste des posts ayant ce tag
         $liste = $thetag->getPosts();
     } else {
         if (isset($_GET["datem"]) && isset($_GET["datey"])) {
             $y = $_GET["datey"];
             $mo = $_GET["datem"];
             // titre
             if ($mo != "-1") {
                 $moenlettre = array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre");
                 $moenlettre = $moenlettre[intval($mo) - 1];
                 $title = "Liste des posts de {$moenlettre} {$y}";
             } else {
                 $title = "Liste des posts de {$y}";
             }
             $liste = array();
             $po = Post::getAll();
             foreach ($po as $lol) {
                 $date = $lol->getDate();
                 if ($mo != "-1") {
                     if (substr($date, 0, 7) == "{$y}-{$mo}") {
                         // vérifie que l'article correspond au mois/année
                         $liste[] = $lol;
                     }
                 } else {
                     if (substr($date, 0, 4) == "{$y}") {
                         // vérifie que l'article correspond au mois/année
                         $liste[] = $lol;
                     }
                 }
             }
         } else {
             $title = "Liste des derniers posts";
             $liste = Post::getAllOrderBy("id DESC");
         }
     }
     // récupération des données des articles
     $articles = array();
     for ($i = 0; $i < count($liste); $i++) {
         $p = Post::getById($liste[$i]->id);
         $p = $p[0];
         $articles[$i] = array('date' => "Le " . $p->getDate() . " à " . $p->getHour(), 'title' => $p->getTitle(), 'content' => $p->getBody(), 'nbComments' => $p->getNbComments(), 'link' => 'index.php?module=post&action=view&id=' . $p->id);
     }
     // récupération de tous les tags pour le nuage
     $at = Tag::getAll();
     $alltags = array();
     foreach ($at as $ta) {
         $alltags[] = $ta->getTag();
     }
     // récupération des années
     $ay = Post::getAll();
     $allyears = array();
     foreach ($ay as $ye) {
         $couranty = explode("-", $ye->getDate());
         $couranty = $couranty[0];
         if (!in_array($couranty, $allyears)) {
             $allyears[] = $couranty;
         }
     }
     // login
     if ($maincont->isLoggued()) {
         $login = $_SESSION["login"];
     } else {
         $login = "nobody";
     }
     // affichage de la vue
     include_once "view.php";
     $v = new HomeDisplayView();
     $v->display($login, $alltags, $allyears, $title, $articles);
 }
开发者ID:rogerwilko,项目名称:Yet-Another-Blog,代码行数:79,代码来源:controler.php

示例12: upload

 public function upload()
 {
     if (func_num_args() != 0) {
         return false;
     }
     // Check that the function is called with correct number of arguments
     if ($_SESSION['auth'] == 'true' && $_SESSION['id'] == '1') {
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             $files = array();
             $fdata = $_FILES['upload'];
             $post_id = $_POST['post_id'];
             $finalDir = "uploads/{$post_id}/";
             if (is_array($fdata['name'])) {
                 for ($i = 0; $i < count($fdata['name']); ++$i) {
                     $files[] = array('name' => $fdata['name'][$i], 'tmp_name' => $fdata['tmp_name'][$i]);
                 }
             } else {
                 $files[] = $fdata;
             }
             $i = 0;
             foreach ($files as $file) {
                 // each uploaded file
                 try {
                     $error = $_FILES["upload"]["error"][$i];
                     if ($errors[$i] != 0) {
                         throw new Exception(Tools::file_upload_error_message($errors[$i]));
                     }
                     // Sets all the accepded file formats.
                     $accepted_filetypes = array('image/gif', 'image/jpg', 'image/jpeg', 'image/pjpeg', 'application/msword', 'application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/x-pdf', 'application/vnd.oasis.opendocument.text');
                     // Checks if the uploaded file is of a approved format
                     if (!in_array($_FILES["upload"]["type"][$i], $accepted_filetypes)) {
                         throw new Exception("Ikke godkjent filtype! Godkjente filtyper: .gif, .jpeg, .doc, .pdf, .docx, .odt");
                     }
                     // Checks if the uploaded file is of a approved size
                     //var_dump($_FILES["upload"]["size"][$i]);
                     if ($_FILES["upload"]["size"][$i] > 5242880) {
                         throw new Exception("Filen din er for stor! Filen er st&oslash;rre enn 5MB!");
                     }
                     // Checks if the uploaded file already is uploaded at the post
                     if (file_exists("uploads/{$post_id}/" . $file["name"])) {
                         throw new Exception($file["name"] . " fins allerede. ");
                     }
                 } catch (Exception $e) {
                     $vars = array('error' => $e->getMessage());
                     new View('upload.tpl', $vars);
                     return true;
                 }
                 // Checks if the folder for the post exists, if not it creates the folder
                 if (!file_exists($finalDir)) {
                     @mkdir($finalDir);
                 }
                 move_uploaded_file($file["tmp_name"], "uploads/{$post_id}/" . $file["name"]);
                 Router::redirect("post/{$post_id}");
                 //							echo "Stored in: " . "uploads/$post_id/" . $file["name"];
                 $i++;
             }
             // each uploaded file end
         } else {
             // POST REQUEST end
             $posts = Post::getAll();
             new View('upload.tpl', array('posts' => $posts));
         }
         // other REQUEST end
         return true;
         // Router feedback
     }
     // upload function end
 }
开发者ID:ringe,项目名称:RAS,代码行数:68,代码来源:Controller.class.php


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