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


PHP comment::create方法代码示例

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


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

示例1: create_comment_for_user_test

 public function create_comment_for_user_test()
 {
     $rand = rand();
     $root = ORM::factory("item", 1);
     $admin = user::lookup(2);
     $comment = comment::create($root, $admin, "text_{$rand}", "name_{$rand}", "email_{$rand}", "url_{$rand}");
     $this->assert_equal($admin->full_name, $comment->author_name());
     $this->assert_equal($admin->email, $comment->author_email());
     $this->assert_equal($admin->url, $comment->author_url());
     $this->assert_equal("text_{$rand}", $comment->text);
     $this->assert_equal(1, $comment->item_id);
     $this->assert_equal("REMOTE_ADDR", $comment->server_remote_addr);
     $this->assert_equal("HTTP_USER_AGENT", $comment->server_http_user_agent);
     $this->assert_equal("HTTP_ACCEPT", $comment->server_http_accept);
     $this->assert_equal("HTTP_ACCEPT_CHARSET", $comment->server_http_accept_charset);
     $this->assert_equal("HTTP_ACCEPT_ENCODING", $comment->server_http_accept_encoding);
     $this->assert_equal("HTTP_ACCEPT_LANGUAGE", $comment->server_http_accept_language);
     $this->assert_equal("HTTP_CONNECTION", $comment->server_http_connection);
     $this->assert_equal("HTTP_HOST", $comment->server_http_host);
     $this->assert_equal("HTTP_REFERER", $comment->server_http_referer);
     $this->assert_equal("HTTP_USER_AGENT", $comment->server_http_user_agent);
     $this->assert_equal("QUERY_STRING", $comment->server_query_string);
     $this->assert_equal("REMOTE_ADDR", $comment->server_remote_addr);
     $this->assert_equal("REMOTE_HOST", $comment->server_remote_host);
     $this->assert_equal("REMOTE_PORT", $comment->server_remote_port);
     $this->assert_true(!empty($comment->created));
 }
开发者ID:xafr,项目名称:gallery3,代码行数:27,代码来源:Comment_Helper_Test.php

示例2: _create

 /**
  * Add a new comment to the collection.
  * @see REST_Controller::_create($resource)
  */
 public function _create($comment)
 {
     $item = ORM::factory("item", $this->input->post("item_id"));
     access::required("view", $item);
     $form = comment_3nids::get_add_form($item);
     $valid = $form->validate();
     if ($valid) {
         if (user::active()->guest && !$form->add_comment->inputs["name"]->value) {
             $form->add_comment->inputs["name"]->add_error("missing", 1);
             $valid = false;
         }
         if (!$form->add_comment->text->value) {
             $form->add_comment->text->add_error("missing", 1);
             $valid = false;
         }
     }
     if ($valid) {
         $comment = comment::create($item, user::active(), $form->add_comment->text->value, $form->add_comment->inputs["name"]->value, $form->add_comment->email->value, $form->add_comment->url->value);
         $active = user::active();
         if ($active->guest) {
             $form->add_comment->inputs["name"]->value("");
             $form->add_comment->email->value("");
             $form->add_comment->url->value("");
         } else {
             $form->add_comment->inputs["name"]->value($active->full_name);
             $form->add_comment->email->value($active->email);
             $form->add_comment->url->value($active->url);
         }
     }
     url::redirect(url::site("comments_3nids?item_id=" . $item->id));
 }
开发者ID:regi01,项目名称:gallery3-contrib,代码行数:35,代码来源:comments_3nids.php

示例3: _create

 /**
  * Add a new comment to the collection.
  * @see REST_Controller::_create($resource)
  */
 public function _create($comment)
 {
     $item = ORM::factory("item", $this->input->post("item_id"));
     access::required("view", $item);
     $form = comment::get_add_form($item);
     $valid = $form->validate();
     if ($valid) {
         if (user::active()->guest && !$form->add_comment->inputs["name"]->value) {
             $form->add_comment->inputs["name"]->add_error("missing", 1);
             $valid = false;
         }
         if (!$form->add_comment->text->value) {
             $form->add_comment->text->add_error("missing", 1);
             $valid = false;
         }
     }
     if ($valid) {
         $comment = comment::create($item, user::active(), $form->add_comment->text->value, $form->add_comment->inputs["name"]->value, $form->add_comment->email->value, $form->add_comment->url->value);
         $active = user::active();
         if ($active->guest) {
             $form->add_comment->inputs["name"]->value("");
             $form->add_comment->email->value("");
             $form->add_comment->url->value("");
         } else {
             $form->add_comment->inputs["name"]->value($active->full_name);
             $form->add_comment->email->value($active->email);
             $form->add_comment->url->value($active->url);
         }
         $form->add_comment->text->value("");
         print json_encode(array("result" => "success", "resource" => $comment->state == "published" ? url::site("comments/{$comment->id}") : null, "form" => $form->__toString()));
     } else {
         print json_encode(array("result" => "error", "form" => $form->__toString()));
     }
 }
开发者ID:Okat,项目名称:gallery3,代码行数:38,代码来源:comments.php

示例4: deleting_an_item_deletes_its_comments_too_test

 public function deleting_an_item_deletes_its_comments_too_test()
 {
     $rand = rand();
     $album = album::create(ORM::factory("item", 1), "test_{$rand}", "test_{$rand}");
     $comment = comment::create($album, identity::guest(), "text_{$rand}", "name_{$rand}", "email_{$rand}", "url_{$rand}");
     $album->delete();
     $deleted_comment = ORM::factory("comment", $comment->id);
     $this->assert_false($deleted_comment->loaded);
 }
开发者ID:ChrisRut,项目名称:gallery3,代码行数:9,代码来源:Comment_Event_Test.php

示例5: cant_view_comments_for_unviewable_items_test

 public function cant_view_comments_for_unviewable_items_test()
 {
     $root = ORM::factory("item", 1);
     $album = album::create($root, rand(), rand(), rand());
     $comment = comment::create($album, user::guest(), "text", "name", "email", "url");
     user::set_active(user::guest());
     // We can see the comment when permissions are granted on the album
     access::allow(group::everybody(), "view", $album);
     $this->assert_equal(1, ORM::factory("comment")->viewable()->where("comments.id", $comment->id)->count_all());
     // We can't see the comment when permissions are denied on the album
     access::deny(group::everybody(), "view", $album);
     $this->assert_equal(0, ORM::factory("comment")->viewable()->where("comments.id", $comment->id)->count_all());
 }
开发者ID:Okat,项目名称:gallery3,代码行数:13,代码来源:Comment_Model_Test.php

示例6: setup

 public function setup()
 {
     Input::instance()->ip_address = "1.1.1.1";
     Kohana::$user_agent = "Akismet_Helper_Test";
     $root = ORM::factory("item", 1);
     $this->_comment = comment::create($root, user::guest(), "This is a comment", "John Doe", "john@gallery2.org", "http://gallery2.org");
     foreach ($this->_comment->list_fields("comments") as $name => $field) {
         if (strpos($name, "server_") === 0) {
             $this->_comment->{$name} = substr($name, strlen("server_"));
         }
     }
     $this->_comment->save();
     module::set_var("akismet", "api_key", "TEST_KEY");
 }
开发者ID:xafr,项目名称:gallery3,代码行数:14,代码来源:Akismet_Helper_Test.php

示例7: create

 /**
  * Add a new comment to the collection.
  */
 public function create($id)
 {
     $item = ORM::factory("item", $id);
     access::required("view", $item);
     $form = comment::get_add_form($item);
     $valid = $form->validate();
     if ($valid) {
         if (identity::active_user()->guest && !$form->add_comment->inputs["name"]->value) {
             $form->add_comment->inputs["name"]->add_error("missing", 1);
             $valid = false;
         }
         if (!$form->add_comment->text->value) {
             $form->add_comment->text->add_error("missing", 1);
             $valid = false;
         }
     }
     if ($valid) {
         $comment = comment::create($item, identity::active_user(), $form->add_comment->text->value, $form->add_comment->inputs["name"]->value, $form->add_comment->email->value, $form->add_comment->url->value);
         $active = identity::active_user();
         if ($active->guest) {
             $form->add_comment->inputs["name"]->value("");
             $form->add_comment->email->value("");
             $form->add_comment->url->value("");
         } else {
             $form->add_comment->inputs["name"]->value($active->full_name);
             $form->add_comment->email->value($active->email);
             $form->add_comment->url->value($active->url);
         }
         $form->add_comment->text->value("");
         $view = new Theme_View("comment.html", "other", "comment-fragment");
         $view->comment = $comment;
         print json_encode(array("result" => "success", "view" => $view->__toString(), "form" => $form->__toString()));
     } else {
         print json_encode(array("result" => "error", "form" => $form->__toString()));
     }
 }
开发者ID:viosca,项目名称:gallery3,代码行数:39,代码来源:comments.php

示例8: _add_comment

 private static function _add_comment()
 {
     srand(time());
     $photos = ORM::factory("item")->where("type", "photo")->find_all()->as_array();
     $users = ORM::factory("user")->find_all()->as_array();
     if (empty($photos)) {
         return;
     }
     if (module::is_active("akismet")) {
         akismet::$test_mode = 1;
     }
     $photo = $photos[array_rand($photos)];
     $author = $users[array_rand($users)];
     $guest_name = ucfirst(self::_random_phrase(rand(1, 3)));
     $guest_email = sprintf("%s@%s.com", self::_random_phrase(1), self::_random_phrase(1));
     $guest_url = sprintf("http://www.%s.com", self::_random_phrase(1));
     comment::create($photo, $author, self::_random_phrase(rand(8, 500)), $guest_name, $guest_email, $guest_url);
 }
开发者ID:needful,项目名称:gallery3-contrib,代码行数:18,代码来源:developer_task.php

示例9: add_comments

 function add_comments($count)
 {
     srand(time());
     $photos = ORM::factory("item")->where("type", "photo")->find_all()->as_array();
     $users = ORM::factory("user")->find_all()->as_array();
     if (empty($photos)) {
         url::redirect("scaffold");
     }
     if (module::is_active("akismet")) {
         akismet::$test_mode = 1;
     }
     for ($i = 0; $i < $count; $i++) {
         $photo = $photos[array_rand($photos)];
         $author = $users[array_rand($users)];
         $guest_name = ucfirst($this->random_phrase(rand(1, 3)));
         $guest_email = sprintf("%s@%s.com", $this->random_phrase(1), $this->random_phrase(1));
         $guest_url = sprintf("http://www.%s.com", $this->random_phrase(1));
         comment::create($photo, $author, $this->random_phrase(rand(8, 500)), $guest_name, $guest_email, $guest_url);
     }
     url::redirect("scaffold");
 }
开发者ID:xafr,项目名称:gallery3,代码行数:21,代码来源:scaffold.php


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