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


PHP Annotation::get_respond_to_topic方法代码示例

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


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

示例1: index

 function index()
 {
     $url = 'http://www.plurk.com/p/67k6st#response-1739920625';
     $text1 = '[CODING D17] 晚上睡覺時天氣、室溫、冷氣、電扇、被子的厚度與蓋的方法,組合起來就可以預測隔天會不會一整天過敏。但我還沒有明顯地分辨出他們的關聯。';
     $text2 = '變項太多,這回歸的組合也不知道要排到什麼時候orz';
     $note = '「西瓜牛奶去冰的話可能沒有滿杯喔」由於店員這樣說,所以我改口跟他說不用去冰好了……結果還是一樣沒有滿杯orz';
     $email = 'puddingchen.35@gmail.com';
     $email_siroma = 'siroma@gmail.com';
     $scope1 = $this->annotation_scope->create_scope(3, 20, $text1, $url);
     $scope2 = $this->annotation_scope->create_scope(26, 40, $text2, $url);
     $scope_coll = new Annotation_scope_collection();
     $scope_coll->add_scope($scope1);
     $scope_coll->add_scope($scope2);
     $len = $scope_coll->get_scope_length();
     $user = $this->user->create_user($url, $email);
     $user_siroma = $this->user->create_user($url, $email_siroma);
     $annotation = $this->annotation->create_annotation($user, $scope_coll);
     $this->unit->run($annotation->get_id(), 9999, '是否有正確地存入資料庫?');
     $scope_coll2 = $annotation->get_scopes();
     $this->unit->run($scope_coll2->get_scope_length(), $len, '測試get_scopes()');
     $annotation->set_note($note);
     $this->unit->run($annotation->get_note(), $note, '測試get_note()');
     $annotation->set_type(3);
     $type = $annotation->get_type();
     $this->unit->run($type->get_name(), 'annotation.type.confusion', '測試get_type()');
     $user = $annotation->get_user();
     $this->unit->run($user->get_email(), $email, '測試get_user()');
     $this->unit->run($user->get_email(), $email, '測試get_user()');
     $annotation_topic = $this->annotation->create_annotation($user_siroma, $scope2);
     $annotation_topic_id = $annotation_topic->get_id();
     $annotation->set_respond_to_topic($annotation_topic);
     $topic = $annotation->get_respond_to_topic();
     $this->unit->run($topic->get_id(), $annotation_topic_id, '測試respond_to_topic()');
     //來測試respond_to_coll
     $scope3 = $this->annotation_scope->create_scope(104, 135, $note, $url);
     $annotation_respond = $this->annotation->create_annotation($user_siroma, $scope3);
     //$annotation_coll = new Annotation_collection($annotation_respond);
     $annotation->set_respond_to_coll($annotation_respond);
     $coll = $annotation->get_respond_to_coll();
     $this->unit->run($coll->length(), 1, '測試respond_to_coll()的length');
     ///$this->unit->run($coll->get_item(0)->get_id()
     //        , $annotation_respond->get_id()
     //        , '測試respond_to_coll()的get_id() | '.$annotation->get_id());
     $annotation->set_feature(1, 1);
     $feature = $annotation->get_feature(1);
     $this->unit->run($feature->get_name(), 'annotation.feature.location', 'set_feature之後又get_feature->get_name()');
     $this->unit->run($feature->get_value(), '1', 'set_feature之後又get_feature->get_value()');
     $annotation->set_feature(1, 2);
     $feature = $annotation->get_feature(1);
     $this->unit->run($feature->get_value(), '2', '再一次set_feature之後又get_feature->get_value()');
     $score_number = 2.36978;
     $score_number2 = 1.36978;
     $annotation->set_score(0, $score_number);
     $score = $annotation->get_score(0);
     $this->unit->run($score->get_name(), 'annotation.score.integrated', 'set_score之後又get_score->get_name()');
     $this->unit->run($score->get_score(), $score_number, 'set_score之後又get_score->get_value()');
     $annotation->set_score(0, $score_number2);
     $score = $annotation->get_score(0);
     $this->unit->run($score->get_score(), $score_number2, '再一次set_score之後又get_score->get_score()');
     $email_like = 'siroma@gmail.com';
     $user_like = $this->user->create_user($url, $email_like);
     $this->unit->run_false($user->get_id(), $user_like->get_id(), '建立一個user_like,跟user不同人吧?');
     $this->unit->run_false($annotation->get_user()->get_id(), $user_like->get_id(), 'user_like,跟標註的作者user不同人吧?');
     $this->unit->run($annotation->get_like_count(), 0, 'like測試,加入user_like之前 get_like_count()');
     $annotation->add_like($user_like);
     $this->unit->run($annotation->get_like_count(), 1, 'like測試,加入user_like之後 get_like_count()');
     $annotation->remove_like($user_like);
     $this->unit->run($annotation->get_like_count(), 0, 'like測試,移除user_like之後 get_like_count()');
     $annotation->add_like($user_like);
     $this->unit->run($annotation->get_like_count(), 1, 'like測試,再加入user_like之後 get_like_count()');
     $this->unit->run($annotation->get_user()->get_unread_notification_count(), 1, '更新之前,到底annotation的作者收到幾封未讀通知呢?應該是有like的一封');
     $annotation->update();
     $this->unit->run(TRUE, TRUE, '======================更新完畢======================');
     $this->unit->run($user_siroma->get_unread_notification_count(), 1, '更新之後,由於user_siroma被設為topic跟respond的對象,所以user_siroma應該只會收到1封通知');
     $db = $this->db;
     $db->from('annotation2like_count');
     $db->where('annotation_id', $annotation->get_id());
     $db->select('like_count');
     $query = $db->get();
     $row = $query->row_array();
     $like_count = intval($row['like_count']);
     $this->unit->run($like_count, 1, '測試annotation2like_count');
     //----------------------------------------------------------------------------
     //搜尋看看吧
     $id = $annotation->get_id();
     $annotation2 = new Annotation($id);
     $scope_coll3 = $annotation2->get_scopes();
     $this->unit->run($annotation2->get_id(), $id, '$annotation2的id是否跟當初設定的相同?');
     $this->unit->run($scope_coll3->get_scope_length(), $len, '取出$annotation2之後,測試scopes');
     $this->unit->run($scope_coll3->length(), 2, '取出$annotation2之後,測試scopes有幾個');
     $this->unit->run($scope_coll3->get_anchor_speech(), $scope_coll2->get_anchor_speech(), '取出$annotation2之後,測試scopes的get_anchor_speech()');
     $this->unit->run($annotation2->get_note(), $note, '取出$annotation2之後,測試note');
     $type2 = $annotation2->get_type();
     $this->unit->run($type2->get_name(), 'annotation.type.confusion', '取出$annotation2之後,測試type');
     $user2 = $annotation2->get_user();
     $this->unit->run($user2->get_email(), $email, '取出$annotation2之後,測試get_user()');
     $text2 = '雖然這邊太吵了應該聽不到尖叫聲,不過應該是會有人間叫';
     $this->unit->run($annotation2->get_like_count(), 1, '搜尋之後,like測試,已經加入user_like');
     $this->unit->run_false($annotation2->get_user()->get_id(), $user_like->get_id(), '確認一下兩個標註應該是不同人吧?');
     $annotation2->set_note($text2);
//.........这里部分代码省略.........
开发者ID:119155012,项目名称:kals,代码行数:101,代码来源:ut_annotation.php

示例2: _create_process

 /**
  * 實際上進行建立檔案的過程
  * @param Object $json
  * @return Object
  */
 private function _create_process($json)
 {
     // 是否啟用偵錯
     $debug = FALSE;
     if ($debug) {
         $this->output->enable_profiler(TRUE);
     }
     $data = json_to_object($json);
     //檢視資料
     //test_msg('annotation_setter._create_process', $json);
     //{
     //  "feature_location":[0,2,4],
     //  "note":"%3Cp%3E%0A%09test%3C%2Fp%3E%0A",
     //  "policy_type":1,
     //  "is_like":false,
     //  "like_count":0,
     //  "feature_recommend_scope":[[6391,6434]],
     //  "scope":[
     //      [6391,6433,"3.%20This%20distraction%20effect%20of%20the%20visual%20cue%20map%20has%20not%20been%20proven.%20In%20the%20future%2C%20a%20systematic%20experimental%20design%20should%20be%20conducted%20to%20examine%20whether%20the%20visual%20cue%20map%20distracts%20learners\'%20reading%2C%20thus%20affecting%20their%20reading%20comprehension"]
     //      ],
     //  "type":1
     //   }
     //先將權限設成管理者
     set_ignore_authorize(true);
     //取得參考網址資料跟位於session的user
     $url = $this->url;
     $user = $this->user;
     //取得來自$json的範圍資料
     $scope_coll_data = $data->scope;
     $scope_coll = $this->annotation_scope_collection->import_webpage_data($url, $scope_coll_data);
     //建立標註
     $annotation = $this->annotation->create_annotation($user, $scope_coll);
     $data = $this->_setup_annotation($annotation, $data);
     set_ignore_authorize(true);
     $annotation = new Annotation($annotation->get_id());
     // 建立推薦標註
     //test_msg("_create_process", 'before create recommend');
     if ($annotation->is_respond() === FALSE) {
         //test_msg("_create_process", 'before _setup_scores_recommend($annotation)');
         $annotation = $this->_setup_scores_recommend($annotation);
         //test_msg("_create_process", 'before get_recommen()');
         $recommend = $annotation->get_recommend();
         //test_msg("_create_process", 'after get_recommen()');
         if (isset($recommend)) {
             $recommend_data = $recommend->export_webpage_data($this->url);
             if (isset($recommend_data)) {
                 $data['recommend'] = $recommend_data;
             }
         }
     }
     //test_msg("_create_process", 'after create recommend');
     // 標註共識的分數都重新計算
     $annotation = new Annotation($annotation->get_id());
     $consensus_coll = $annotation->get_consensus_coll();
     foreach ($consensus_coll as $consensus) {
         $this->_setup_scores($consensus);
         $consensus->update();
     }
     // --------------------------------------------
     //log區
     $array_data = $annotation->export_webpage_data($this->url);
     $action = 13;
     if (isset($data['recommend'])) {
         $action = 14;
     }
     if ($annotation->is_respond()) {
         $action = 20;
         //如果是回自己,那就改成27
         $topic = $annotation->get_respond_to_topic();
         if ($topic->get_user()->equals($annotation->get_user())) {
             $action = 27;
         }
     }
     $user_id = NULL;
     if (isset($user)) {
         $user_id = $user->get_id();
     }
     kals_log($this->db, $action, array('memo' => $array_data, 'user_id' => $user_id));
     //test_msg("_create_process", 'before context_complete()');
     //context_complete();
     set_ignore_authorize(false);
     return $data;
 }
开发者ID:119155012,项目名称:kals,代码行数:88,代码来源:annotation_setter.php


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