Commit ed10bef4 authored by Kevin's avatar Kevin
Browse files

Split into different boards

Add Config-File
parent c685b870
<?php
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',
'name' => 'Hacksaar Infoboard',
// preloading 'log' component
'preload' => array('log'),
// autoloading model and component classes
'import' => array(
'application.models.*',
'application.components.*',
),
'modules' => array(
// uncomment the following to enable the Gii tool
/*
'gii' => array(
'class' => 'system.gii.GiiModule',
'password' => 'yourPass',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters' => array('127.0.0.1', '::1'),
),
*/
),
// application components
'components' => array(
'user' => array(
// enable cookie-based authentication
'allowAutoLogin' => true,
),
// uncomment the following to enable URLs in path-format
'urlManager' => array(
'showScriptName' => false,
'urlFormat' => 'path',
'rules' => array(
//'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/board/<board:\d+>' => '<controller>/index',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
''=>'message/index',
),
),
/*
'db'=>array(
'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
),
*/
// uncomment the following to use a MySQL database
'db' => array(
'connectionString' => 'mysql:host=localhost;dbname=XXX', //SetDatabase
'emulatePrepare' => true,
'username' => '', //YourUser
'password' => '', //YourPass
'charset' => 'utf8',
),
'errorHandler' => array(
// use 'site/error' action to display errors
'errorAction' => 'site/error',
),
'log' => array(
'class' => 'CLogRouter',
'routes' => array(
array(
'class' => 'CFileLogRoute',
'levels' => 'error, warning',
),
// uncomment the following to show log messages on web pages
array(
'class' => 'CWebLogRoute',
'levels' => 'error, warning',
),
),
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params' => array(
// this is used in contact page
'adminEmail' => 'kkrieger85@gmail.com',
),
);
......@@ -9,7 +9,8 @@ class MessageController extends Controller {
}
public function actionIndex() {
$this->render('index');
$board = Yii::app()->request->getQuery('board', '1');
$this->render('index', array("board" => $board));
}
public function actionNew() {
......@@ -21,6 +22,7 @@ class MessageController extends Controller {
}
public function actionSse() {
$board = Yii::app()->request->getQuery('board', '1'); //Default: 1 == Nachrichten, die ueberall angezeigt werden
header("Content-Type: text/event-stream\n\n");
header('Cache-Control: no-cache');
......@@ -31,7 +33,8 @@ class MessageController extends Controller {
//Lade Nachrichten der letzten 24 Stunden (max 10 Nachrichten)
$criteria = new CDbCriteria;
$criteria->select = 'id, text, created, infotype';
$criteria->addCondition('board = "1"');
$criteria->addCondition('board = "'.$board.'"');
$board != 1?$criteria->addCondition('board = "1"', 'OR'):'';
$criteria->addCondition('deleted IS NULL');
......@@ -97,7 +100,7 @@ class MessageController extends Controller {
// Validate ok! Saving your data from form okay!
// Send a response back!
header('Content-type: application/json');
echo json_encode(array('result' => true, 'data' => 'Valid Data, Saving succeeded')); // Use CJSON::encode() instead of json_encode() if you are encoding a Yii model
echo json_encode(array('result' => true, 'data' => 'Nachricht wurde gespeichert')); // Use CJSON::encode() instead of json_encode() if you are encoding a Yii model
Yii::app()->end(); // Properly end the appÏ
} else {
// Validate ok! Saving your data from form failed!
......
This diff is collapsed.
......@@ -56,11 +56,38 @@
<ul class="nav navbar-nav">
<li>
<a href="<?php echo Yii::app()->createAbsoluteUrl("message/"); ?>">
<a href="<?php echo Yii::app()->createAbsoluteUrl("message/", array('board'=>1)); ?>">
<button type="button" class="btn btn-default navbar-btn">
<span class="glyphicon glyphicon-th-list">
</span>
Infoscreen
Infoboard
</button>
</a>
</li>
<li>
<a href="<?php echo Yii::app()->createAbsoluteUrl("message/", array('board'=>2)); ?>">
<button type="button" class="btn btn-default navbar-btn">
<span class="glyphicon glyphicon-wrench">
</span>
Werkstatt
</button>
</a>
</li>
<li>
<a href="<?php echo Yii::app()->createAbsoluteUrl("message/", array('board'=>3)); ?>">
<button type="button" class="btn btn-default navbar-btn">
<span class="glyphicon glyphicon-fire">
</span>
Plenum
</button>
</a>
</li>
<li>
<a href="<?php echo Yii::app()->createAbsoluteUrl("message/", array('board'=>1337)); ?>">
<button type="button" class="btn btn-default navbar-btn">
<span class="glyphicon glyphicon-eye-open">
</span>
Trollette
</button>
</a>
</li>
......
......@@ -31,7 +31,7 @@
if (typeof (EventSource) !== "undefined")
{
var source = new EventSource("<?php echo Yii::app()->createAbsoluteUrl("message/sse/"); ?>");
var source = new EventSource("<?php echo Yii::app()->createAbsoluteUrl("message/sse/board/".$board); ?>");
source.addEventListener('messages', function(result) {
if (('#' + result.lastEventId) !== '') {
......@@ -40,12 +40,12 @@
$('#' + result.lastEventId + ' .panel-body').html(resultData.text);
$('#' + result.lastEventId + ' .panel-heading').html(resultData.created + " (" + result.lastEventId + ")");
$('#' + result.lastEventId).addClass("panel panel-" + resultData.infotype);
// $('#' + result.lastEventId + " a.embed").oembed(null, {
// maxWidth: 600,
// maxHeight: 400,
// //includeHandle: true,
// embedMethod: 'auto',
// });
$('#' + result.lastEventId + " a.embed").oembed(null, {
maxWidth: 600,
maxHeight: 400,
//includeHandle: true,
embedMethod: 'auto',
});
$('#placeholder').hide();
}
......
......@@ -14,8 +14,55 @@
<div id="txtInput" class=" news well ">
<textarea id="txtContent" placeholder="Enter text ..." style="width: 100%; height: 300px">
</textarea>
</div>
</div>
<div class="col-lg-3 col-md-3" id="options">
<div class="form-group" id="board">
<label for="board">Infoboard</label>
<select class="form-control">
<option value="1">Alle</option>
<option value="2">Werkstatt</option>
<option value="3">Plenum</option>
<option value="1337">Trollette</option>
</select>
</div>
<div class="form-group" id="infotype">
<label for="meldung">Meldung</label>
<select class="form-control">
<option value="info">Information</option>
<option value="warning">Hinweis</option>
<option value="danger">Wichtig</option>
</select>
</div>
<button id="txtSubmit" type="button" class="btn btn-primary btn-block">Speichern</button>
</div>
<!-- Modal -->
<div id="alertBox" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-body">
<div class="alert"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default " data-dismiss="modal">Schließen</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
<script type="text/javascript">
$('#txtResult').hide();
$('#txtContent').wysihtml5({
......@@ -78,51 +125,4 @@
});
});
</script>
</div>
</div>
<div class="col-lg-3 col-md-3" id="options">
<div class="form-group" id="board">
<label for="board">Infoboard</label>
<select class="form-control">
<option value="1">Alle</option>
<option value="2">Werkstatt</option>
<option value="3">Plenum</option>
<option value="1337">Trollette</option>
</select>
</div>
<div class="form-group" id="infotype">
<label for="meldung">Meldung</label>
<select class="form-control">
<option value="info">Information</option>
<option value="warning">Hinweis</option>
<option value="danger">Wichtig</option>
</select>
</div>
<button id="txtSubmit" type="button" class="btn btn-primary">Speichern</button>
</div>
<!-- Modal -->
<div id="alertBox" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-body">
<div class="alert"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Schließen</button>
</div>
</div>
</div>
</div>
\ No newline at end of file
</script>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment