本文整理匯總了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);
}