當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CommentForm::getAttributeLabel方法代碼示例

本文整理匯總了PHP中CommentForm::getAttributeLabel方法的典型用法代碼示例。如果您正苦於以下問題:PHP CommentForm::getAttributeLabel方法的具體用法?PHP CommentForm::getAttributeLabel怎麽用?PHP CommentForm::getAttributeLabel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CommentForm的用法示例。


在下文中一共展示了CommentForm::getAttributeLabel方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionCreate

 public function actionCreate($id = 0, $callback)
 {
     // @todo 暫時無用
     if (!request()->getIsAjaxRequest() || !request()->getIsPostRequest()) {
         throw new CHttpException(500);
     }
     $data = array();
     $model = new CommentForm();
     $model->attributes = $_POST['CommentForm'];
     if ($model->validate() && ($comment = $model->save())) {
         $data['errno'] = 0;
         $data['text'] = t('ajax_comment_done');
         $data['html'] = 'x';
         // @todo 反回此條評論的html代碼
     } else {
         $data['errno'] = 1;
         $attributes = array_keys($model->getErrors());
         foreach ($attributes as $attribute) {
             $labels[] = $model->getAttributeLabel($attribute);
         }
         $errstr = join(' ', $labels);
         $data['text'] = sprintf(t('ajax_comment_error'), $errstr);
     }
     echo json_encode($data);
     exit(0);
 }
開發者ID:rainsongsky,項目名稱:24beta,代碼行數:26,代碼來源:CommentController.php

示例2: actionComment

 public function actionComment($callback, $id = 0)
 {
     $id = (int) $id;
     $callback = strip_tags(trim($callback));
     if (!request()->getIsAjaxRequest() || !request()->getIsPostRequest() || empty($callback)) {
         throw new CHttpException(500);
     }
     $data = array();
     $model = new CommentForm();
     $model->attributes = $_POST['CommentForm'];
     $model->content = h($model->content);
     if ($id > 0 && ($quote = Comment::model()->findByPk($id))) {
         $quoteTitle = sprintf(t('comment_quote_title'), $quote->authorName);
         $html = '<fieldset class="beta-comment-quote"><legend>' . $quoteTitle . '</legend>' . $quote->content . '</fieldset>';
         $model->content = $html . $model->content;
     }
     if ($model->validate() && ($comment = $model->save())) {
         $data['errno'] = 0;
         $data['text'] = t('ajax_comment_done');
         $data['html'] = $this->renderPartial('/comment/_one', array('comment' => $comment), true);
         // @todo 反回此條評論的html代碼
     } else {
         $data['errno'] = 1;
         $attributes = array_keys($model->getErrors());
         foreach ($attributes as $attribute) {
             $labels[] = $model->getAttributeLabel($attribute);
         }
         $errstr = join(' ', $labels);
         $data['text'] = sprintf(t('ajax_comment_error'), $errstr);
     }
     echo $callback . '(' . json_encode($data) . ')';
     exit(0);
 }
開發者ID:rainsongsky,項目名稱:24beta,代碼行數:33,代碼來源:PostController.php


注:本文中的CommentForm::getAttributeLabel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。