Skip to content

Commit 58e85c9

Browse files
committed
Initial push for chat package
0 parents  commit 58e85c9

File tree

3,075 files changed

+876661
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,075 files changed

+876661
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php namespace Syntax\Core;
2+
3+
use Illuminate\Support\ServiceProvider;
4+
5+
class ChatServiceProvider extends ServiceProvider {
6+
7+
/**
8+
* Indicates if loading of the provider is deferred.
9+
*
10+
* @var bool
11+
*/
12+
protected $defer = false;
13+
14+
/**
15+
* Bootstrap the application events.
16+
*
17+
* @return void
18+
*/
19+
public function boot()
20+
{
21+
$this->package('syntax/chat');
22+
}
23+
24+
/**
25+
* Register the service provider.
26+
*
27+
* @return void
28+
*/
29+
public function register()
30+
{
31+
$this->shareWithApp();
32+
// $this->registerAlias();
33+
$this->loadConfig();
34+
$this->registerViews();
35+
// $this->activateProfiler();
36+
// $this->registerProfilerRouting();
37+
}
38+
39+
/**
40+
* Share the package with application
41+
*
42+
* @return void
43+
*/
44+
protected function shareWithApp()
45+
{
46+
$this->app['chat'] = $this->app->share(function($app)
47+
{
48+
return true;
49+
});
50+
}
51+
52+
/**
53+
* Load the config for the package
54+
*
55+
* @return void
56+
*/
57+
protected function loadConfig()
58+
{
59+
$this->app['config']->package('syntax/chat', __DIR__.'/../../../config');
60+
}
61+
62+
/**
63+
* Register views
64+
*
65+
* @return void
66+
*/
67+
protected function registerViews()
68+
{
69+
$this->app['view']->addNamespace('chat', __DIR__.'/../../../views');
70+
}
71+
72+
/**
73+
* Get the services provided by the provider.
74+
*
75+
* @return array
76+
*/
77+
public function provides()
78+
{
79+
return array();
80+
}
81+
82+
}

src/config/chatConfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"debug" : true,
3+
"port" : 1337,
4+
"backLog" : 100,
5+
"backFill" : 30,
6+
"apiEndPoint" : "YOUR_URL/api/chat-room-log",
7+
"connectionMessage" : true
8+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
class Core_ApiVersionOneController extends BaseController {
4+
5+
public function getChatRoomLog($chatRoomId, $backLog = 30)
6+
{
7+
$this->skipView();
8+
9+
$chatRoomId = e($chatRoomId);
10+
11+
$messageOutput = array();
12+
13+
$chatMessages = Chat::where('chat_room_id', '=', $chatRoomId)
14+
->orderBy('created_at','desc')
15+
->take($backLog)
16+
->get();
17+
18+
foreach ($chatMessages as $messageObject) {
19+
$parsedChatMessage = BBCode::parse($messageObject->message);
20+
21+
$newMessage = array();
22+
$newMessage['text'] = "<small class='muted'>({$messageObject->created_at})</small> ".HTML::link('/profile/'. $messageObject->user->uniqueId, $messageObject->user->username, array('target' => '_blank')) .": {$parsedChatMessage} <br />";
23+
$messageOutput[] = $newMessage;
24+
}
25+
26+
$messageOutput = array_reverse($messageOutput);
27+
28+
return json_encode($messageOutput);
29+
}
30+
}

0 commit comments

Comments
 (0)