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


PHP Comments::find方法代碼示例

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


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

示例1: listAction

 public function listAction()
 {
     $comments = Comments::find(['order' => 'id ASC']);
     if (!count($comments)) {
         $this->_status['response']['status'] = false;
         $this->_status['response']['code'] = 102;
         return $this->response->setJsonContent($this->_status);
     }
     foreach ($comments as $comment) {
         $this->_status['response']['comment'][] = ['post_id' => $comment->posts->id, 'posts_title' => $comment->posts->title, 'comment_name' => $comment->name, 'comment_email' => $comment->email, 'comment' => $comment->comment, 'date' => $comment->created_at];
     }
     return $this->response->setJsonContent($this->_status);
 }
開發者ID:gomasiyo,項目名稱:cms,代碼行數:13,代碼來源:CommentController.php

示例2: launch

 function launch()
 {
     global $interface;
     global $user;
     global $configArray;
     // Process Delete Comment
     if (isset($_GET['delete']) && is_object($user)) {
         $comment = new Comments();
         $comment->id = $_GET['delete'];
         if ($comment->find(true)) {
             if ($user->id == $comment->user_id) {
                 $comment->delete();
             }
         }
     }
     $interface->assign('id', $_GET['id']);
     if (isset($_REQUEST['comment'])) {
         if (!$user) {
             $interface->assign('recordId', $_GET['id']);
             $interface->assign('comment', $_REQUEST['comment']);
             $interface->assign('followup', true);
             $interface->assign('followupModule', 'EContentRecord');
             $interface->assign('followupAction', 'UserComments');
             $interface->setPageTitle('You must be logged in first');
             $interface->assign('subTemplate', '../MyResearch/login.tpl');
             $interface->setTemplate('view-alt.tpl');
             $interface->display('layout.tpl', 'UserComments' . $_GET['id']);
             exit;
         }
         $result = $this->saveComment();
     }
     $interface->assign('user', $user);
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $_GET['id'];
     $eContentRecord->find(true);
     $recordDriver = new EcontentRecordDriver();
     $recordDriver->setDataObject($eContentRecord);
     $interface->setPageTitle(translate('Comments') . ': ' . $recordDriver->getBreadcrumb());
     $this->loadEContentComments();
     $interface->assign('subTemplate', 'view-comments.tpl');
     $interface->setTemplate('view.tpl');
     // Display Page
     $interface->display('layout.tpl');
 }
開發者ID:bryandease,項目名稱:VuFind-Plus,代碼行數:44,代碼來源:UserComments.php

示例3: deleteComment

 /**
  * Delete a comment
  *
  * @param int    $id   ID of comment to delete
  * @param object $user User whose comment is being deleted.
  *
  * @return bool        True for success, false for failure.
  * @access public
  */
 public static function deleteComment($id, $user)
 {
     $comment = new Comments();
     $comment->id = $id;
     if ($comment->find(true)) {
         if ($user->id == $comment->user_id) {
             $comment->delete();
             return true;
         }
     }
     return false;
 }
開發者ID:bharatm,項目名稱:NDL-VuFind,代碼行數:21,代碼來源:UserComments.php

示例4: saveItem

 public function saveItem()
 {
     $cat_id = Input::get('cat_id');
     $item_id = Input::get('id');
     //獲取表單
     if ($cat_id == 0) {
         //新聞編輯
         $title = Input::get('title');
         $content = Input::get('content');
         $abstract = Input::get('abstract');
         $item = News::find($item_id);
     } else {
         if ($cat_id == 1) {
             //項目編輯
             $title = Input::get('title');
             $content = Input::get('content');
             $abstract = Input::get('abstract');
             $begin_time = Input::get('begin_time');
             $end_time = Input::get('end_time');
             $item = Researches::find($item_id);
         } else {
             if ($cat_id == 2) {
                 //通知編輯
                 //
                 $title = Input::get('title');
                 $content = Input::get('content');
                 $item = Notices::find($item_id);
             } else {
                 if ($cat_id == 3) {
                     //課程編輯
                     $course_name = Input::get('course_name');
                     $course_info = Input::get('course_info');
                     $teacher_address = Input::get('teacher_address');
                     $teacher_mail = Input::get('teacher_mail');
                     $TA_name = Input::get('TA_name');
                     $TA_address = Input::get('TA_address');
                     $TA_mail = Input::get('TA_mail');
                     $item = Courses::find($item_id);
                     $homeworks = Courses::find($item_id)->homework;
                     $coursewares = Courses::find($item_id)->courseware;
                     $course_notices = Courses::find($item_id)->comments;
                     foreach ($course_notices as $notice) {
                         $update_notice = Comments::find($notice->id);
                         $update_notice->comment = Input::get('course_notice_content' . $notice->id);
                         $update_notice->updated_at = date("Y-m-d H:i:s");
                         $update_notice->save();
                     }
                     foreach ($homeworks as $homework) {
                         //對已有項進行編輯
                         $delete_or_not = Input::get('homework_delete' . $homework->id);
                         if ($delete_or_not) {
                             //如果標記為刪除則將已有作業進行刪除
                             $delete_item = Homework::find($homework->id);
                             $delete_item->delete();
                         } else {
                             $update_item = Homework::find($homework->id);
                             $update_item->homework_item = Input::get('homework_label' . $homework->id);
                             $update_item->submit_deadline = Input::get('homework_submit_time' . $homework->id);
                             $update_item->deliver_deadline = Input::get('homework_deliver_time' . $homework->id);
                             $update_item->updated_at = date("Y-m-d H:i:s");
                             $update_item->save();
                         }
                     }
                     foreach ($coursewares as $courseware) {
                         $update_item = Courseware::find($courseware->id);
                         $update_item->label = Input::get('courseware_label' . $courseware->id);
                         $update_file_source = 'courseware_ppt' . $courseware->id;
                         $new_source = HomeController::upload_course($item_id, $update_file_source);
                         if ($new_source != "") {
                             //跟新源的同時將舊的課件刪除
                             HomeController::delete_file($update_item->source);
                             $update_item->source = $new_source;
                         } else {
                         }
                         $update_item->updated_at = date("Y-m-d H:i:s");
                         $update_item->save();
                     }
                 }
             }
         }
     }
     //保存數據
     if ($item) {
         //表中已經存在該條目
         if ($cat_id == 0) {
             //新聞編輯
             $item->title = $title;
             $item->content = $content;
             $item->abstract = $abstract;
             $item->save();
             return Redirect::to(URL::to('/news-detail', [$item_id]));
         } else {
             if ($cat_id == 1) {
                 //項目編輯
                 $item->title = $title;
                 $item->content = $content;
                 $item->abstract = $abstract;
                 $item->begin_time = $begin_time;
                 $item->end_time = $end_time;
                 $item->save();
//.........這裏部分代碼省略.........
開發者ID:Konaeu,項目名稱:ubicom,代碼行數:101,代碼來源:HomeController.php

示例5: DeleteComment

 function DeleteComment()
 {
     require_once ROOT_DIR . '/services/MyResearch/lib/Comments.php';
     global $user;
     global $configArray;
     // Process Delete Comment
     if (is_object($user)) {
         $comment = new Comments();
         $comment->id = $_GET['commentId'];
         $comment->source = 'eContent';
         if ($comment->find(true)) {
             if ($user->id == $comment->user_id) {
                 $comment->delete();
             }
         }
     }
     return '<result>true</result>';
 }
開發者ID:bryandease,項目名稱:VuFind-Plus,代碼行數:18,代碼來源:AJAX.php

示例6: _getReviewTitles

 private function _getReviewTitles($reviewTag)
 {
     //Load a list of reviews based on the tag
     $comments = new Comments();
     $comments->whereAdd("comment like \"%#" . mysql_escape_string($reviewTag) . '"');
     $comments->find();
     $recordIds = array();
     $reviews = array();
     $datesSaved = array();
     while ($comments->fetch()) {
         $resourceId = $comments->resource_id;
         //Load the resource from the database
         $resource = new Resource();
         $resource->id = $comments->resource_id;
         $resource->find(true);
         $recordIds[$resource->record_id] = $resource->record_id;
         $comment = preg_replace('/#.*/', '', $comments->comment);
         $reviews[$resource->record_id] = $comment;
         $datesSaved[$resource->record_id] = $comments->created;
     }
     $titles = $this->loadTitleInformationForIds($recordIds, $reviews, $datesSaved);
     return array('success' => true, 'listName' => $reviewTag, 'listDescription' => 'Tagged reviews', 'titles' => $titles, 'cacheLength' => 24);
 }
開發者ID:bryandease,項目名稱:VuFind-Plus,代碼行數:23,代碼來源:ListAPI.php

示例7: readConfig

// Retrieve values from configuration file
$configArray = readConfig();
// Setup time zone
date_default_timezone_set($configArray['Site']['timezone']);
// Setup Local Database Connection
ConnectionManager::connectToDatabase();
// Setup index connection
ConnectionManager::connectToIndex();
// Delete the expired searches -- this cleans up any junk left in the database
// from old search histories that were not caught by the session garbage collector.
$count = 0;
$fixed = 0;
$searchObject = SearchObjectFactory::initSearchObject();
$searchObject->disableLogging();
$comments = new Comments();
if ($comments->find()) {
    while ($comments->fetch()) {
        $commentsRecord = new Comments_record();
        $commentsRecord->comment_id = $comments->id;
        if ($commentsRecord->find(true)) {
            $query = 'local_ids_str_mv:"' . addcslashes($commentsRecord->record_id, '"') . '"';
            $searchObject->setQueryString($query);
            $result = $searchObject->processSearch();
            $searchObject->close();
            if (PEAR::isError($result)) {
                PEAR::raiseError($result->getMessage());
            }
            if ($result['response']['numFound'] > 0) {
                $idArray = $result['response']['docs'][0]["local_ids_str_mv"];
                if ($comments->verifyLinks($idArray)) {
                    ++$fixed;
開發者ID:bharatm,項目名稱:NDL-VuFind,代碼行數:31,代碼來源:verify_record_links.php


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