Exemplo n.º 1
0
 function actionSelect()
 {
     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         if ($_GET['type'] == 'rss') {
             $obj = new Rss();
             $obj->getReport("http://lenta.ru/rss/last24");
             $obj->parser();
         } elseif ($_GET['type'] == 'twitter') {
             $obj = new Twitter();
             $obj->getReport("https://twitter.com/_nezed");
         }
     }
 }
Exemplo n.º 2
0
 public function add($moment_id, $tweet_id, $twitter_id, $screen_name, $tweeted_at, $text)
 {
     if (!Twitter::find()->where(['moment_id' => $moment_id])->andWhere(['tweet_id' => $tweet_id])->exists()) {
         $i = new Twitter();
         $i->moment_id = $moment_id;
         $i->tweet_id = $tweet_id;
         $i->twitter_id = $twitter_id;
         $i->screen_name = $screen_name;
         $i->tweeted_at = $tweeted_at;
         $i->text = $text;
         $i->save();
     }
 }
Exemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Twitter::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'moment_id' => $this->moment_id, 'tweet_id' => $this->tweet_id, 'twitter_id' => $this->twitter_id, 'tweeted_at' => $this->tweeted_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'screen_name', $this->screen_name])->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'link', $this->link]);
     return $dataProvider;
 }
Exemplo n.º 4
0
 public function actionBrowse_twitter($id)
 {
     // browse twitter results for moment $id
     $dataProvider = new ActiveDataProvider(['query' => Twitter::find()->where(['moment_id' => $id])->orderBy('tweeted_at ASC')]);
     return $this->render('browse_twitter', ['dataProvider' => $dataProvider, 'moment_id' => $id]);
 }
Exemplo n.º 5
0
 public static function purge($moment_id)
 {
     Gram::deleteAll('moment_id=' . $moment_id);
     Twitter::deleteAll('moment_id=' . $moment_id);
 }
Exemplo n.º 6
0
 /**
  * Finds the Twitter model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Twitter the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Twitter::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }