コード例 #1
0
ファイル: posts.php プロジェクト: nathggns/anchor-cms
 public function edit($id)
 {
     // find article
     if (($article = Posts::find(array('id' => $id))) === false) {
         return Response::redirect($this->admin_url . '/posts');
     }
     // process post request
     if (Input::method() == 'POST') {
         if (Posts::update($id)) {
             // redirect path
             return Response::redirect($this->admin_url . '/posts/edit/' . $id);
         }
     }
     // get comments
     $comments = Comments::list_all(array('post' => $id));
     $pending = array();
     foreach ($comments as $comment) {
         if ($comment->status == 'pending') {
             $pending[] = $comment->id;
         }
     }
     $pending = count($pending);
     // get posts page
     $page = Pages::find(array('id' => Config::get('metadata.posts_page')));
     Template::render('posts/edit', array('article' => $article, 'comments' => $comments, 'page' => $page, 'pending' => $pending));
 }
コード例 #2
0
ファイル: views-529.php プロジェクト: aodkrisda/phalcon-code
 public function showAction()
 {
     //Pass all the posts to the views
     $this->view->setVar("posts", Posts::find());
     //Using the magic setter
     $this->view->posts = Posts::find();
     //Passing more than one variable at the same time
     $this->view->setVars(array('title' => $post->title, 'content' => $post->content));
 }
コード例 #3
0
 /**
  * Поиск должностей по параметрам
  */
 public function searchAction()
 {
     $query = Criteria::fromInput($this->di, "Posts", array_merge($_GET, $_POST));
     $this->persistent->parameters = $query->getParams();
     $parameters = $this->persistent->parameters;
     if (!is_array($parameters)) {
         $parameters = array();
     }
     $posts = \Posts::find($parameters)->toArray(true);
     $this->view->disable();
     $this->response->setContentType('application/json', 'UTF-8');
     echo json_encode($posts);
 }
コード例 #4
0
ファイル: PostsController.php プロジェクト: poorman/MyCMS
 public function indexAction()
 {
     $this->view->disable();
     //no view here
     $post_array = array();
     $posts = Posts::find();
     $posts->rewind();
     while ($posts->valid()) {
         $post = $posts->current();
         array_unshift($post_array, array('title' => $post->getTitle(), 'content' => $post->getContent(), 'id' => $post->id()));
         $posts->next();
     }
     return (new \Phalcon\Http\Response())->setContent(json_encode($post_array));
 }
コード例 #5
0
 public function getAction()
 {
     $this->view->disable();
     if ($this->request->isGet() == true) {
         $posts = Posts::find();
         foreach ($posts as $post) {
             $this->_posts[] = $post;
         }
         $this->response->setJsonContent(array("posts" => $this->_posts));
         $this->response->setStatusCode(200, "OK");
         $this->response->send();
     } else {
         $this->response->setStatusCode(404, "Not Found");
     }
 }
コード例 #6
0
ファイル: HomeController.php プロジェクト: mitap45/Daily
 public function showPost($postID)
 {
     $memberID = Session::get('key');
     $post = Posts::find($postID);
     $member = Members::find($post->memberID);
     $data = array('post' => $post, 'memberID' => $memberID, 'member' => $member);
     if (Session::get('adminLoggedIn')) {
         //adminse
         return View::make('admin/showPostForAdmin', $data);
     }
     if ($memberID == "") {
         //member değilse
         return View::make('showPost', $data);
     }
     return View::make('member/showPostForMember', $data);
     //membersa
 }
コード例 #7
0
 public function postsAction()
 {
     $request = new Request();
     $this->view->setVar("title", "Посади");
     $search = trim($request->get("search"));
     $pageCount = $request->get("page-count") ? $request->get("page-count") : $this->session->get("page-count");
     if ($pageCount) {
         $this->session->set("page-count", $pageCount);
     }
     $orderColumn = trim($request->get("order-column")) . " " . trim($request->get("order-type"));
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => \Posts::find(array("order" => trim($orderColumn) ? $orderColumn : "title ASC", "conditions" => "title LIKE ?1", "bind" => array(1 => "%" . $search . "%"))), "limit" => $pageCount ? $pageCount : 30, "page" => $request->get("page")));
     $page = $paginator->getPaginate();
     $this->view->page = $page;
     $this->view->countItems = count($page->items);
     $this->view->search = $search;
     $this->view->orderColumn = $request->get("order-column");
     $this->view->orderType = $request->get("order-type");
     $this->view->pageCount = $pageCount;
 }
コード例 #8
0
ファイル: routes.php プロジェクト: rubenvincenten/anchor-site
 public function article($slug = '')
 {
     // find article
     $params = array('slug' => $slug);
     // allow admin to view unpublished posts
     if (Users::authed() === false) {
         $params['status'] = 'published';
     }
     if (($article = Posts::find($params)) === false) {
         return Response::error(404);
     }
     // add comment
     if (Input::method() == 'POST') {
         if (Comments::add($article->id)) {
             $page = IoC::resolve('posts_page');
             return Response::redirect($page->slug . '/' . $article->slug);
         }
     }
     // register single item for templating functions
     IoC::instance('article', $article, true);
     Template::render('article');
 }
コード例 #9
0
 public function getPostsAction($gid = NULL)
 {
     if ($gid == NULL) {
         if ($this->request->get("stafflistGroup")) {
             $gid = $this->request->get("stafflistGroup");
         } else {
             $result = NULL;
         }
     } else {
         $posts = \Posts::find();
         $stafflists = \Stafflist::find("stafflist_group=" . $gid);
         $result = array();
         foreach ($posts as $post) {
             if (!$this->checkPostInStaff($post, $stafflists)) {
                 $result[] = $post->toArray(true);
             }
         }
     }
     $this->view->disable();
     $this->response->setContentType('application/json', 'UTF-8');
     echo json_encode($result);
 }
コード例 #10
0
 /**
  * Searches for posts
  */
 public function searchAction()
 {
     $numberPage = 1;
     if ($this->request->isPost()) {
         $query = Criteria::fromInput($this->di, "Posts", $_POST);
         $this->persistent->parameters = $query->getParams();
     } else {
         $numberPage = $this->request->getQuery("page", "int");
     }
     $parameters = $this->persistent->parameters;
     if (!is_array($parameters)) {
         $parameters = array();
     }
     $parameters["order"] = "id";
     $posts = Posts::find($parameters);
     if (count($posts) == 0) {
         $this->flash->notice("The search did not find any posts");
         return $this->dispatcher->forward(array("controller" => "posts", "action" => "index"));
     }
     $paginator = new Paginator(array("data" => $posts, "limit" => 10, "page" => $numberPage));
     $this->view->page = $paginator->getPaginate();
 }
コード例 #11
0
 public function index()
 {
     $posts = Posts::find();
     return Rs::p(1, 'All Posts', $posts);
 }
コード例 #12
0
ファイル: views-269.php プロジェクト: aodkrisda/phalcon-code
 public function showAction()
 {
     //Pass all the posts to the views
     $this->view->setVar("posts", Posts::find());
 }
コード例 #13
0
ファイル: posts.php プロジェクト: jsdecena/synthesis
        $data['created_at'] = $posts[$i]['created_at'];
        $author = Users::find($posts[$i]['author_id']);
        $data['author'] = $author->firstname;
    }
    $results[] = $data;
    die(json_encode($results));
});
$app->post('/api/v1/posts', function () use($app) {
    $posts = new Posts();
    $posts->title = $app->request()->post('title');
    $posts->slug = str_replace(' ', '-', $app->request()->post('slug'));
    $posts->content = $app->request()->post('content');
    $posts->author_id = $app->request()->post('post_type');
    $posts->author_id = $app->request()->post('author_id');
    $posts->save();
    die(json_encode($posts));
});
$app->put('/api/v1/posts/:id', function ($id) use($app) {
    $posts = Posts::find($id);
    $posts->title = $app->request()->post('title');
    $posts->slug = str_replace(' ', '-', $app->request()->post('slug'));
    $posts->content = $app->request()->post('content');
    $posts->author_id = $app->request()->post('author_id');
    $posts->save();
    die(json_encode($posts));
});
$app->delete('/api/v1/posts/:id', function ($id) use($app) {
    $posts = Posts::find($id);
    $posts->delete();
    die(json_encode($posts));
});
コード例 #14
0
ファイル: pages.php プロジェクト: jsdecena/slimapp
});
//GET THE PARTICULAR USER
$app->get('/api/v1/pages/:slug', function ($slug) use($app) {
    $response = $app->response();
    $response->header('Access-Control-Allow-Origin', '*');
    $pages = Posts::where('slug', $slug)->first();
    $response->write(json_encode($pages));
});
$app->post('/api/v1/pages', function () use($app) {
    $pages = new Posts();
    $pages->title = $app->request()->post('title');
    $pages->slug = str_replace(' ', '-', $app->request()->post('slug'));
    $pages->content = $app->request()->post('content');
    $pages->author_id = $app->request()->post('author_id');
    $pages->save();
    die(json_encode($pages));
});
$app->put('/api/v1/pages/:id', function ($id) use($app) {
    $pages = Posts::find($id);
    $pages->title = $app->request()->post('title');
    $pages->slug = str_replace(' ', '-', $app->request()->post('slug'));
    $pages->content = $app->request()->post('content');
    $pages->author_id = $app->request()->post('author_id');
    $pages->save();
    die(json_encode($pages));
});
$app->delete('/api/v1/pages/:id', function ($id) use($app) {
    $pages = Posts::find($id);
    $pages->delete();
    die(json_encode($pages));
});
コード例 #15
0
ファイル: base.route.php プロジェクト: kuslahne/SlimBlog
<?php

$app->get('/(:page)', function ($page = 1) use($app, $settings) {
    $p = Posts::count();
    $pages = ceil($p / $settings->post_per_page);
    if ($page > $pages) {
        $app->pass();
    }
    $posts = Posts::orderBy('creation', 'desc')->skip($settings->post_per_page * ($page - 1))->take($settings->post_per_page)->get();
    $arr = array();
    //Posts
    foreach ($posts as $post) {
        if ($post['active'] == 'true') {
            $post['author'] = Users::get_author($post['user_id']);
            $post['date'] = date('d-m-Y H:i', $post['creation']);
            $post['url'] = $app->request->getUrl() . $app->request->getPath() . 'post/' . $post['id'];
            if ($settings->truncate == 'true') {
                $text = truncate_to_n_words($post['text'], 70, $post['url']);
                $post['text'] = $app->markdown->parse($text);
            } else {
                $post['text'] = $app->markdown->parse($post['text']);
            }
            $post['count'] = Posts::find($post['id'])->comments->count();
            $arr[] = $post;
        }
    }
    $app->render('posts.html', array('posts' => $arr, 'pages' => $pages, 'page' => $page));
})->conditions(array('page' => '\\d+'));
コード例 #16
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy()
 {
     $post = Posts::find(Input::get('id'));
     $post->delete();
     return Redirect::to('/managePosts');
 }
コード例 #17
0
ファイル: mvc.php プロジェクト: LWFeng/xnx
LEVEL_LAYOUT            Generates the presentation to the controller layout.                        3
LEVEL_AFTER_TEMPLATE    Generates the presentation to the templates after the controller layout.    4
LEVEL_MAIN_LAYOUT       Generates the presentation to the main layout. File views/index.phtml       5
//*/
// 选择视图(Picking Views)
$this->view->pick("products/search");
$this->view->pick(array('products'));
$this->view->pick(array(1 => 'search'));
// 关闭视图(Disabling the view)
$this->view->disable();
// OR return a ‘response’ object
return $this->response->redirect('index/index');
// 使用局部模版(Using Partials)
$this->partial("shared/ad_banner");
$this->partial("shared/ad_banner", array('id' => $site->id, 'size' => 'big'));
//Pass all the posts to the views
$this->view->setVar("posts", Posts::find());
//Using the magic setter
$this->view->posts = Posts::find();
//Passing more than one variable at the same time
$this->view->setVars(array('title' => $post->title, 'content' => $post->content));
// Using more than one template engine
$this->view->registerEngines(array(".my-html" => 'MyTemplateAdapter', ".phtml" => 'Phalcon\\Mvc\\View\\Engine\\Php', ".volt" => 'Phalcon\\Mvc\\View\\Engine\\Volt'));
//Setting up the view component
$di->set('view', function () {
    $view = new \Phalcon\Mvc\View();
    //A trailing directory separator is required
    $view->setViewsDir('../app/views/');
    $view->registerEngines(array(".phtml" => 'Phalcon\\Mvc\\View\\Engine\\Php', ".volt" => 'Phalcon\\Mvc\\View\\Engine\\Volt'));
    return $view;
}, true);
コード例 #18
0
 /**
  * We simply pass all the posts created to the view
  */
 public function indexAction()
 {
     $this->view->setVar('posts', Posts::find());
 }
コード例 #19
0
 public function indexAction()
 {
     $posts = Posts::find();
     $this->view->setVar('posts', $posts);
 }
コード例 #20
0
ファイル: post.route.php プロジェクト: kuslahne/SlimBlog
<?php

$app->get('/post/:id', function ($id) use($app) {
    if ($post = Posts::find($id)) {
        $flash = $app->view()->getData('flash');
        $error = isset($flash['error']) ? $flash['error'] : '';
        $post->author = Users::get_author($post->user_id);
        $post->date = date('d-m-Y H:i', $post->creation);
        $post->text = $app->markdown->parse($post->text);
        $post->count = Posts::find($post->id)->comments->count();
        $comments = Posts::find($post->id)->comments;
        $redirect = $app->request->getUrl() . $app->request->getPath();
        $app->render('post.html', array('post' => $post, 'error' => $error, 'comments' => $comments, 'redirect' => $redirect));
    } else {
        $app->render('404_post.html');
    }
})->conditions(array('page' => '\\d+'));
$app->post('/post/comment/new', function () use($app, $settings) {
    $username = $app->request->post('username');
    $url = filter_var($app->request->post('url'), FILTER_SANITIZE_URL);
    $email = $app->request->post('email');
    $text = filter_var($app->request->post('text'), FILTER_SANITIZE_STRING);
    $post_id = $app->request->post('post_id');
    $redirect = $app->request->post('redirect');
    if ($username == "") {
        $app->flash('error', 1);
        $app->redirect($settings->base_url . '/post/' . $post_id);
    }
    if ($url == "") {
        $app->flash('error', 2);
        $app->redirect($settings->base_url . '/post/' . $post_id);
コード例 #21
0
 /**
  * RSS feed
  */
 public function feedAction()
 {
     $posts = Posts::find(array('order' => 'published DESC', 'limit' => 10));
     $rss_posts = array();
     foreach ($posts as $post) {
         $post->rss_date = date("D, d M Y H:i:s O", strtotime($post->published));
         $rss_posts[] = $post;
     }
     $this->view->posts = $rss_posts;
     $this->view->setRenderLevel(Phalcon\Mvc\View::LEVEL_ACTION_VIEW);
 }
コード例 #22
0
ファイル: MemberController.php プロジェクト: mitap45/Daily
 public function deletePost($postID)
 {
     $memberID = Session::get('key');
     $post = Posts::find($postID);
     $post->delete();
     if (Session::get('adminLoggedIn')) {
         //silen kişi admin ise
         return Redirect::to('admin');
     }
     $posts = DB::table('posts')->where('memberID', $memberID)->orderBy('created_at', 'desc')->get();
     $member = Members::find($memberID);
     $followings = DB::table('follow')->join('members', 'members.memberID', '=', 'follow.followMemberID')->where('follow.memberID', $memberID)->select('members.name', 'members.surname', 'members.memberID')->get();
     $followers = DB::table('follow')->join('members', 'members.memberID', '=', 'follow.memberID')->where('follow.followMemberID', $memberID)->select('members.name', 'members.surname', 'members.memberID')->get();
     return View::make('member/profile', array('delete' => true, 'member' => $member, 'posts' => $posts, 'followers' => $followers, 'followings' => $followings));
 }
コード例 #23
0
ファイル: PostController.php プロジェクト: Abenaman/ggc-talk
 /**
  * Show the form for editing the specified post.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $post = Posts::find($id);
     return View::make('posts.edit', compact('post'));
 }
コード例 #24
0
ファイル: EntryController.php プロジェクト: gomasiyo/cms
 public function allAction()
 {
     $posts = Posts::find(['order' => 'id ASC']);
     foreach ($posts as $post) {
         $content = preg_split('/\\[more\\]/', $post->content);
         $tags = Tags::findByPosts_id($post->id);
         $tag_array = [];
         if ($tags) {
             foreach ($tags as $tag) {
                 $tag_array[] = $tag->tag;
             }
         }
         $categories = Categories::findByPosts_id($post->id);
         $category_array = [];
         if ($categories) {
             foreach ($categories as $category) {
                 $category_array[] = $category->category;
             }
         }
         $this->_status['response']['entry'][] = ['id' => $post->id, 'author' => $post->users->name, 'title' => $post->title, 'content' => $content, 'tags' => $tag_array, 'categoris' => $category_array];
     }
     return $this->response->setJsonContent($this->_status);
 }