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


PHP Software::comments_permalink方法代码示例

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


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

示例1: post_comment

 /**
  *	@fn post_comment
  *	@short Action method that receives a comment for a software product.
  */
 public function post_comment()
 {
     $conn = Db::get_connection();
     if (!$this->request->is_post()) {
         $this->redirect_to(array('action' => 'index'));
     }
     $software = new Software();
     if ($software->find_by_id($_POST['software_id']) === FALSE) {
         $this->flash(l('No such software'), 'error');
         $this->redirect_to(array('action' => 'index'));
     }
     if (!Email::is_valid($_POST['email'])) {
         $this->flash(l('Please enter a valid email address'), 'error');
         $this->redirect_to($software->comments_permalink());
     }
     if (!Antispam::check_math()) {
         $this->flash(Antispam::random_comment(), 'error');
         $this->redirect_to($software->comments_permalink());
     }
     // A static class method would be infinitely better...
     $comment = new SoftwareComment($_POST);
     $comment->created_at = date('Y-m-d H:i:s');
     $comment->save();
     // Send an email to notify this comment
     $email = new SoftwareCommentEmail(array('comment' => $comment, 'name' => $_POST['author'], 'email' => $_POST['email'], 'URL' => $_POST['URL']));
     $email->send();
     if (isset($_POST['remember_me'])) {
         $this->set_credentials($_POST['author'], $_POST['email'], $_POST['URL']);
     }
     // Expires the cache of Comments feed
     $this->expire_cached_page(array('controller' => 'feed', 'action' => 'software_comments', 'id' => $_POST['software_id']));
     $this->redirect_to_software_page(array('id' => $_POST['software_id'], 'subview' => 'comments', 'hash' => 'comment-' . $comment->id));
     Db::close_connection($conn);
 }
开发者ID:emeraldion,项目名称:zelda,代码行数:38,代码来源:software_controller.php


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